首先CGI程序第一行的python位置一定要指定绝对正确的路径
比如我的是这样的
#!d:\python24\python.exe
print "Content-type: text/plain; charset=iso-8859-1\n\n"
print 'Hello python cgi'
复制代码
http.conf文件的配置要改好
ScriptAlias /cgi-bin/ "D:/Program Files/Apache Group/Apache2/cgi-bin/"
<Directory "D:/Program Files/Apache Group/Apache2/cgi-bin">
AllowOverride All
Options All
Order allow,deny
Allow from all
</Directory>
AddHandler cgi-script .py
复制代码
弄好以后重启apache
访问http://127.0.0.1/cgi-bin/hello.py就可以看到输出