我在我的cgi-bin
文件夹中有一个文件test.py
。 该文件是这样的:Python - apache cgi-bin脚本工作/不适用于不同的python安装?
#!/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
时,出现Error 500 Internal Server错误。有任何想法吗?
我已经完成了sudo chmod 755 test.py
,只需要两个版本的标题行就可以调用./test.py
。
编辑:每@ Anony-慕斯的评论,这里是适用了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
** apache错误日志说的是什么? – 2012-07-11 17:27:18
@ Anony-Mousse我已经添加了两行适用的error_log;它看起来像是一个权限错误? – kalaracey 2012-07-11 17:38:00