apache上安装mod_python
一、安装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=========================
保存,测试。
捐赠本站(Donate)
如您感觉文章有用,可扫码捐赠本站!(If the article useful, you can scan the QR code to donate))
- Author: shisekong
- Link: https://blog.361way.com/mod_python/631.html
- License: This work is under a 知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议. Kindly fulfill the requirements of the aforementioned License when adapting or creating a derivative of this work.