使用apache2.4.18设置cgi-bin服务器python [英] setup cgi-bin server python with apache2.4.18

查看:152
本文介绍了使用apache2.4.18设置cgi-bin服务器python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆