我想我犯了一些愚蠢的错误,但我找不到它。试图在 apache 网络服务器上运行一个简单的 python cgi 脚本。我的代码是
#/usr/bin/env python
import cgitb
import cgi
cgitb.enable()
print 'Content-Type: text/html'
print
print '<html>'
print '<head><title>My first Python CGI app</title></head>'
print ' <body>'
print ' <p>something to try<p>'
print ' </body>'
print '</html>'
Run Code Online (Sandbox Code Playgroud)
这段代码在 /usr/lib/cgi-bin 我试图通过 localhost/cgi-bin/test.py 运行它,但它显示500 INTERNAL SERVER ERROR。我尝试更改其权限,但什么也没发生。我能够从 /var/www/html/file_name.html 运行 html 文件所以我尝试在 www/ 和 www/html/(两者中)移动它并制作 cgi-bin 文件夹,没有它,没有解决。
我在 apache2.conf 中添加了这个
<Directory /usr/lib/cgi-bin>
Options +ExecCGI
AddHandler cgi-script .cgi .py
Order allow,deny
Allow from all
</Directory>
Run Code Online (Sandbox Code Playgroud)
和 var/log/apache2/error.log 说
[Tue Jan 13 …