我也是,我的运行环境是:windows xp + Python2.5 + Apache2.2.9 就是不知道怎么样配置Apache才能成功.第六章的6.3(电子档为117页)的例子fig06_03.py(从网上下载的程序)如果我用IIS作为web服务提供者(端口为8088,虚拟目录为d:\www),在浏览器上输入:http://localhost:8088/www/cgi-bin/fig06_03.py是可以正确显示结果,我的显示结果是:Tue Sep 02 20:52:59 2008.
但是如果我用Apache作为web服务提供者(端口为80,根目录已经改成d:\www)在浏览器上输入:http://localhost/cgi-bin/fig06_03.py ,则出现错误的提示如下)
************************************************************
Not Found
The requested URL /cgi-bin/fig06_03.py was not found on this server.
************************************************************
查看Apache的错误日志(C:\Program Files\Apache Software Foundation\Apache2.2\logs\error.log)如下:
************************************************************
[Tue Sep 02 20:25:24 2008] [notice] Child 1480: Starting thread to listen on port 80.
[Tue Sep 02 20:25:24 2008] [notice] Child 3456: All worker threads have exited.
[Tue Sep 02 20:25:24 2008] [notice] Child 3456: Child process is exiting
[Tue Sep 02 20:40:14 2008] [error] [client 127.0.0.1] File does not exist: D:/www/CFIDE
************************************************************
我的Apache配置(httpd.conf)如下(只写出修改的部分):
************************************************************
DocumentRoot "D:/www"
LoadModule python_module modules/mod_python.so
<Directory "D:/www">
Options Indexes FollowSymLinks
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ "D:/www/cgi-bin/"
<Directory "D:/www/cgi-bin">
AllowOverride None
Options None
SetHandler mod_python
PythonHandler mod_python.publisher
Order allow,deny
Allow from all
</Directory>
************************************************************
apache服务正常.
另外我先了一个test.py程序,放在D:\www\cgi-bin.内容如下:
************************************************************
#!C:/Python25/python.exe
# Filename : test.py
def hello():
return "hello world."
print "Hello world!"
************************************************************
如果我在浏览器上输入http://localhost/cgi-bin/test.py,显示:
************************************************************
Not Found
The requested URL /cgi-bin/fig06_03.py was not found on this server.
************************************************************
如果我在浏览器上输入http://localhost/cgi-bin/test.py/hello,显示则正常:
************************************************************
hello world.
************************************************************
我估计应该是apache的配置问题,但是我找过很多的资料,包括mod_python中文文档(链接地址:http://man.chinaunix.net/develop ... hon/mod_python.html).真是有焦头烂额的感觉.请帮助我.谢谢!