【发布时间】:2016-12-17 19:03:26
【问题描述】:
我在/var/www/cgi-bin 中有我的index.py
我的index.py 看起来像这样:
#!/usr/bin/python
print "Content-type:text/html\r\n\r\n"
print '<html>'
print '<head>'
print '<title>Hello Word - First CGI Program</title>'
print '</head>'
print '<body>'
print '<h2>Hello Word! This is my first CGI program</h2>'
print '</body>'
print '</html>'
我的 apache2 /etc/apache2/sites-enabled/000-default.conf 看起来像这样:
<VirtualHost *:80>
<Directory /var/www/cgi-bin>
Options +ExecCGI
AddHandler cgi-script .cgi .py
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
如果还有什么需要修改的,请告诉我,我已经启用了 cgi。
问题是无论我访问哪个 URL,我都会不断收到错误 Not Found localhost 或 localhost/index.py
【问题讨论】:
-
我的 Apache 知识有点生疏,但
index.py是否设置了执行权限位? -
是的
chmod 755 -
你是不是直接尝试了127.0.0.1,而不是localhost?
-
这样做了,没用。
-
将 /etc/apache2/ports.conf 中的监听端口从 80 更改为 8080 等其他端口,然后运行 'sudo systemctl daemon-reload' 和 'sudo service apache2 restart' 然后尝试 127.0 .0.1:8080