1.安装Apache
下载地址:http://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.2.24.tar.gz
1)解压缩
sudo tar xvf httpd-2.4.4.tar.gz
2)进入~/httpd-2.4.4目录,执行
sudo ./configure --prefix=/usr/server/apache2 --enable-module=so
sudo make
sudo make install
2.安装mod_python
下载地址:http://archive.apache.org/dist/httpd/modpython/mod_python-3.3.1.tgz
1)解压缩
sudo tar xvf mod_python-3.3.1.tgz
2)修改下载包中connobject.c中的BUG
需修改mod_python-3.3.1/src/connobject.c中!(b == APR_BRIGADE_SENTINEL(b) 为 !(b == APR_BRIGADE_SENTINEL(bb)
3)配置mod_python
cd mod_python-3.3.1
./configure --with-apxs=/usr/server/apache2/bin/apxs --with-python=/usr/bin/python
4)编译执行
sudo make
sudo make install
成功后/usr/server/apache2/modules目录下应该会出现mod_python.so
ls -l /usr/server/apache2/modules
3.加载mod_python模块
1)修改Apache配置文件/usr/server/apache2/conf/httpd.conf,增加mod_python.so的配置行:
LoadModule python_module /usr/server/apache2/modules/mod_python.so
可以设置MaxRequestsPerChild 1,这样可以在开发阶段不用重启Apache进行测试
<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE config.settings
PythonDebug On
PythonPath "['/home/search/evaluating'] + sys.path"
</Location>
<Location "/media/">
SetHandler None
</Location>
<LocationMatch "\.(jpg|gif|png)$">
SetHandler None
</LocationMatch>