我无法用python cgi解释代码

时间:2014-08-18 19:28:23

标签: python apache cgi

我收到此错误:

127.0.0.1 - - [18/Aug/2014:10:40:49 -0700] "GET /code.py HTTP/1.1" 304 178 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36"

我启用了模块" mod_wsgi"在apache但我解释了" py"文件。我知道这不是php python,但我想试试这个。我的配置如下:

/usr/lib/cgi-bin/code.py

#!/usr/bin/env python
print "Content-Type: text/html"
print
print 'Hello World'

/etc/apache2/sites-available/example-python.conf

<VirtualHost *:80>
   ServerName example-python
   DocumentRoot "/usr/lib/cgi-bin"

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
        AddHandler cgi-script .cgi .py

   Require all granted

    </Directory>


   LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
   #CustomLog logs/localhost.log combined
</virtualhost

0 个答案:

没有答案