一、安装mod_python

针对debian和centos版的linux,安装方式分别如下:

1apt-get install libapache2-mod-python和yum install mod_python

二、配置apache

1cp /etc/httpd/conf.d/python.conf /etc/httpd/conf.d/python.conf_orig
2cat /dev/null > /etc/httpd/conf.d/python.conf
3vi /etc/httpd/conf.d/python.conf

编缉内容如下:

 1LoadModule python_module modules/mod_python.so
 2<Directory /var/www/html/>
 3  Options Indexes FollowSymLinks MultiViews
 4  AllowOverride None
 5  Order allow,deny
 6  allow from all
 7  AddHandler mod_python .py
 8  PythonHandler mod_python.publisher
 9  PythonDebug On
10</Directory>

如果对于.psp类弄,该配置文件如下:

 1LoadModule python_module modules/mod_python.so
 2<Directory /var/www/html/>
 3  Options Indexes FollowSymLinks MultiViews
 4  AllowOverride None
 5  Order allow,deny
 6  allow from all
 7  AddHandler mod_python .psp
 8  PythonHandler mod_python.psp
 9  PythonDebug On
10</Directory>

重启httpd服务

 1#/etc/init.d/httpd restart
 2
 3vi /var/www/html/test.py
 4def index(req):
 5  return "Test successful";
 6
 7.psp的测试内容test.psp刚相应的改为
 8
 9<% req.write("Hello!") %>
10=========================

保存,测试。