【发布时间】:2011-11-07 23:39:11
【问题描述】:
我无法将 Apache Server 配置为运行用 python 编写的 CGI 脚本。我已经搜索了网络,并将所有信息添加到位于“C:\wamp\bin\apache\Apache2.2.17\conf”的“httpd.conf”文件中,修改的详细信息是;
<Directory />
Options FollowSymLinks +ExecCGI
AllowOverride None
Order deny,allow
Deny from all
</Directory>
<Directory "C:\wamp\bin\apache\Apache2.2.17\cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
AddHandler cgi-script .cgi .py
我已在位于“C:\wamp\bin\apache\Apache2.2.17\conf”的“httpd.conf”文件中添加了上述设置并重新启动了 wamp 服务器。
当我尝试运行我的 python CGI 脚本浏览器时,只会打印我的代码,没有错误消息。我使用的链接是; http://localhost/cgi-bin/first_cgi_script.py
我的代码是;
#!c:\Python27\python.exe -u
import time
def printHeader( title ):
print """Content-type: text/html
<?xml version = "1.0" encoding = "UTF-8"?>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<head><title>%s</title></head>
<body>""" % title
printHeader( "Current date and time" )
print time.ctime( time.time() )
print "</body></html>"
需要帮助,谢谢。
【问题讨论】:
-
这当然可能是轻率的,但是......你考虑过Django吗?你已经设置好你的 Apache 服务器,所以你几乎可以开始制作模型了。
标签: python