python-cgi-apache

步骤如下:
1、配置httpd.conf :
设置好CGI目录:
ScriptAlias /cgi-bin/ "F:/web/cgi-bin/"
配置如下:
<Directory "F:/web/cgi-bin">
    AllowOverride None
    Options FollowSymLinks +ExecCGI
    Order allow,deny
    Allow from all
</Directory>
添加CGI扩展名:(去掉注释)
AddHandler cgi-script .cgi
 
2、在.py文件中必须加上#!G:/Python26/python.exe,指能找到python解析文件,例如:
#!G:/Python26/python.exe
import cgi
import cgitb;
cgitb.enable()
print "Content-type:text/html"
print    # 注意此处必须加print打印出一个空行,否则CGI无法解析
print """<HTML>
<HEAD>
<TITLE>CGI Environment</TITLE>
</HEAD>
<BODY>"""
cgi.print_environ()
print "</BODY></HTML>"

 

posted on 2013-03-02 20:54  mtima  阅读(155)  评论(0编辑  收藏  举报

导航