首页 > 解决方案 > 如何解决python(Xampp)的内部服务器错误500

问题描述

我收到此错误:

Server error!
The server encountered an internal error and was unable to complete your request.

Error message:
End of script output before headers: python.py

If you think this is a server error, please contact the webmaster.

Error 500
192.168.64.2
Apache/2.4.41 (Unix) OpenSSL/1.1.1d PHP/7.4.1 mod_perl/2.0.8-dev Perl/v5.16.3

我做了以下事情:

在 httpd.conf 中将 .py 添加到 Addhandler

图片

我做了以下事情:

在 httpd.conf 中将 .py 添加到 Addhandler

图片

我还安装了 pip 和 pymysql

我正在使用 python 3.8.3

我也将权限设置为 chmod 755

在错误日志中它说:

[Sun Jun 07 01:36:53.823419 2020] [cgi:error] [pid 847] [client 192.168.64.1:51293] AH01215: (2)No such file or directory: exec of '/opt/lampp/htdocs/11-python/python.py' failed: /opt/lampp/htdocs/11-python/python.py
[Sun Jun 07 01:36:53.824918 2020] [cgi:error] [pid 847] [client 192.168.64.1:51293] End of script output before headers: python.py

这是我的代码:

#!/usr/local/bin/python3.8
print ('Content-type: text/html\r\n')
print ('\r\n')
print ()
print ('<html>')
print ('<head>')
print ('</head>')
print ('<body>')
print ('Hello Python')
print ('</body>')
print ('</html>')

我正在使用 mac

标签: pythonmacosapachexampppython-3.8

解决方案


推荐阅读