安装 mod_python
1、到 www.modpython.org
下载源码包,解压得到目录,进入该目录,执行:
./configure --with-apxs=/opt/apache/bin/apxs --with-python=/usr/bin/python2.7 make make install
完毕之后,mod_python 会在 /opt/apache/modules 中添加 mod_python.so 库文件,并且在 /opt/python/2.7/lib/python2.7/site-packages 中添加 mod_python 包。
如果编译程序没有检测到 apache 和 python,会报错退出。
如果你将mod_python编译成DSO,那么你需要通过在Apache的配置文件(通常称为httpd.conf 或者 apache.conf)里面加入如下一行,来载入模块:
LoadModule python_module modules/mod_python.so
例子
<Location "/blog"> SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE zlblog.settings PythonInterpreter zlblog PythonDebug On </Location>
留给静态文件一个缝隙
<Location "/blog/(images|css|js)"> SetHandler none </Location>
------------------
注意这里有一个bug
connobject.c: In function '_conn_read': connobject.c:142: error: request for member 'next' in something not a structure or union apxs:Error: Command failed with rc=65536 . make[1]: *** [mod_python.so] Error 1 make[1]: Leaving directory `/usr/src/rpm/BUILD/mod_python-3.3.1/src' make: *** [do_dso] Error 2 需修改mod_python-3.3.1/src/connobject.c中 !(b == APR_BRIGADE_SENTINEL(b) 为 !(b == APR_BRIGADE_SENTINEL(bb) --------------
2.安装django
下载django包后解压,运行
python setup.py install