mod_python配置五步曲
1. 下载 ActivePython-2.5.5.7-win32-x86.msi 并安装
2. 下载mod_python-3.3.1.win32-py2.5-Apache2.2.exe 并安装
** 安装时需要选择python 的安装目录和 apache 的安装目录
3. 编辑 apache/conf/httd.conf , 增添如下内容
Alias /python "D:/opt/workspace/jwhat/src/main/python/test"
<Directory "D:/opt/workspace/jwhat/src/main/python/test">
Options Indexes FollowSymLinks
AllowOverride authconfig
Order allow,deny
Allow from all
AllowOverride All
AllowOverride FileInfo
AddHandler python-program .py
SetHandler mod_python
PythonHandler testcgi
PythonDebug On
</Directory>
LoadModule python_module modules/mod_python.so
4. 编写测试脚本如下: testcgi.py
from mod_python import apache
def handler(req):
req.content_type = "text/html"
req.write("<b>Hello World!</b>")
return apache.OK
5. 测试http://localhost/python