我正在尝试在配置我的服务器后运行一个简单的cgi脚本.
我的脚本看起来像这样:
print "Content-type: text/html"
print
print "<html><head><title>CGI</title></head>"
print "<body>"
print "hello cgi"
print "</body>"
print "</html>"
Run Code Online (Sandbox Code Playgroud)
当我转到我的脚本网址时,http://127.0.0.1/~flybywire/cgi-bin/main.py我得到:
内部服务器错误
服务器遇到内部错误或配置错误,无法完成您的请求.
在error.log我得到以下内容:
[error] (8)Exec format error: exec of '/home/flybywire/www/cgi-bin/main.py' failed
[error] [client 127.0.0.1] Premature end of script headers: main.py
其他信息: Apache/2.2.8 (Ubuntu) DAV/2 SVN/1.4.6 Server at 127.0.0.1 Port 80
Dav*_*itt 11
此外,使用Unix行结尾保存文件(如果这是Linux服务器).你确实使用chmod +x了不是吗?
#!/usr/bin/env python如果您在各种环境(因此env部分)中运行,您可以使用它来覆盖当前运行的Python版本.
| 归档时间: |
|
| 查看次数: |
29988 次 |
| 最近记录: |