1、现在Apache服务器并安装
2、修改Apache安装目录下的配置文件httpd.conf
(1)打开httpd.conf文件,寻找ScriptAlias /cgi-bin/把其后的目录修改为你的.py文件的目录(注意必须是把文件放置在cgi-bin目录下)
(2)增加以下目录
<Directory "和(1)中目录相同">
AllowOverride None
Options FollowSymLinks +ExecCGI
Order allow,deny
Allow from all
</Directory>
3、去掉AddHandler cgi-script .cgi前的“#”
测试:
cgi101.html文件(将其放在Apache安装目录htdocs下)
<html>
<title>Interactive Page</title>
<body>
<form method=POST action="cgi-bin/cgi101.py">
<P><B>Enter your name:</B>
<P><input type=text name=user>
<P><input type=submit>
</form>
</body>
</html>
cgi101.py文件(将其放在第2步中