apache上安装mod_python

一、安装mod_python
针对debian和centos版的linux,安装方式分别如下:
apt-get install libapache2-mod-python和yum install mod_python
二、配置apache
cp /etc/httpd/conf.d/python.conf /etc/httpd/conf.d/python.conf_orig
cat /dev/null > /etc/httpd/conf.d/python.conf
vi /etc/httpd/conf.d/python.conf
编缉内容如下:

LoadModule python_module modules/mod_python.so
<Directory /var/www/html/>
  Options Indexes FollowSymLinks MultiViews
  AllowOverride None
  Order allow,deny
  allow from all
  AddHandler mod_python .py
  PythonHandler mod_python.publisher
  PythonDebug On
</Directory>
如果对于.psp类弄,该配置文件如下:
LoadModule python_module modules/mod_python.so
<Directory /var/www/html/>
  Options Indexes FollowSymLinks MultiViews
  AllowOverride None
  Order allow,deny
  allow from all
  AddHandler mod_python .psp
  PythonHandler mod_python.psp
  PythonDebug On
</Directory>
重启httpd服务
#/etc/init.d/httpd restart
vi /var/www/html/test.py
def index(req):
  return "Test successful";
.psp的测试内容test.psp刚相应的改为
<html>
<body>
<h1><% req.write("Hello!") %></h1>
</body>
</html>
保存,测试。

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注