问题描述
我的index.py
在/var/www/cgi-bin
我的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
看起来像这样:
My apache2 /etc/apache2/sites-enabled/000-default.conf
looks like this :
<VirtualHost *:80>
<Directory /var/www/cgi-bin>
Options +ExecCGI
AddHandler cgi-script .cgi .py
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
让我知道是否还有其他需要修改的地方,我已经启用了cgi.
Let me know if anything else also require any modification, I have already enabled cgi.
问题是无论我访问的URL是什么,我都会不断遇到错误未找到 localhost ,或 localhost/index.py
The problem is no matter whatever URL I visit I keep on getting error Not Found localhost , or localhost/index.py
推荐答案
尝试一下:
启用CGI
a2enmod cgid
chmod a+x /var/www/cgi-bin/index.py
,但检查cgi-bin
目录所有者是wwwdata
吗?
chmod a+x /var/www/cgi-bin/index.py
but check cgi-bin
directory owner is wwwdata
?
每个Virtualhost
都需要一个directory
定义!
杀死所有apache
线程需要一定的时间restart
!
Some time required restart
for killing all apache
threads !
DocumentRoot /var/www/htdocs #A include B if owner are same !
<Directory /var/www/htdocs/cgi-bin/ >
FallbackResource /index.py
Options +ExecCGI -MultiViews -SymLinksIfOwnerMatch -Indexes
Order allow,deny
Allow from all
AddHandler cgi-script .py
</Directory>
这篇关于使用apache2.4.18设置cgi-bin服务器python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!