在简单的CGI脚本内部服务器错误(500)
问题描述:
我想我的配置服务器后运行一个简单的CGI脚本。
I am trying to run a simple cgi script after configuring my server.
我的脚本是这样的:
print "Content-type: text/html"
print
print "<html><head><title>CGI</title></head>"
print "<body>"
print "hello cgi"
print "</body>"
print "</html>"
当我去我的脚本网址 http://127.0.0.1/~flybywire/cgi-bin/main.py
我得到:
When I go to my scripts url http://127.0.0.1/~flybywire/cgi-bin/main.py
I get:
内部服务器错误
服务器遇到一个内部错误或配置错误,无法完成您的请求。
而在 error.log中
我收到以下内容:
[错误](8)Exec的格式错误:的/home/flybywire/www/cgi-bin/main.py'失败EXEC
[错误] [客户端127.0.0.1]脚本头premature月底:main.py
其他信息: 的Apache / 2.2.8(Ubuntu的)DAV / 2 SVN在127.0.0.1端口80 / 1.4.6服务器
答
您可能需要一个#!的/ usr / bin中/ Python的
在你的脚本的顶部告诉Apache来使用Python来执行它。至少,我这样做,它的工作对我来说:-)。
You might need a #!/usr/bin/python
at the top of your script to tell Apache to use Python to execute it. At least, I did that and it worked for me :-) .