我的文件夹test.py
中有一个cgi-bin
用于 apache 的文件。该文件如下所示:
#!/usr/bin/python
print("Content-type: text/html\n\n")
print("Hello world!")
然后,如果我去www.<mywebsite>.com/cgi-bin/test.py
,页面成功显示Hello world!
但是,如果我将我的 python 脚本中的标题行更改为
#!/home/kalaracey/python2.7/bin/python
当我导航到 时www.<mywebsite>.com/cgi-bin/test.py
,我收到错误 500 内部服务器错误。有任何想法吗?
我已经完成sudo chmod 755 test.py
并且可以./test.py
使用两个版本的标题行来调用它。
编辑:根据@Anony-Mousse 的评论,这里是适用的 Apache error_log:
[Wed Jul 11 17:33:40 2012] [error] [client <ipaddress>] (13)Permission denied: exec of '/var/www/cgi-bin/test.py' failed
[Wed Jul 11 17:33:40 2012] [error] [client <ipaddress>] Premature end of script headers: test.py