fedora安装mod_python
2014-04-27 17:03
253 查看
3.1 Installing mod_python
To install mod_python, we simply run:yum install mod_python
3.2 Configuring Apache
Now we must configure Apache so that it can handle Python files. There are two ways of doing so. The first (and default) one is to use the Publisher Handler. It allows you to write pure Python scripts with the extension .py that will be interpreted by Apache. The second way is the PSP Handler. PSP stands for Python Server Pages. It allows you to embed Python code directly in HTML code, similar to PHP. PSP files have the extension .psp.3.2.1 The Publisher Handler
To enable the Publisher Handler, we must edit the mod_python configuration which you can find in /etc/httpd/conf.d/python.conf. This file contains many examples - we make a backup of it and create that file again from scratch. I'm using the default Fedora/CentOS document root /var/www/html here in the<Directory> directive - adjust this to your needs. The important lines are AddHandler mod_python .py and PythonHandler mod_python.publisher:[align=center] [/align]
[align=center] [/align]
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> |
Restart Apache afterwards:
/etc/init.d/httpd restart
Now we create a little Python test script (e.g. /var/www/html/test.py) with pure Python code in it...
vi /var/www/html/test.py
def index(req): return "Test successful"; |
3.2.2 The PSP Handler
To enable the PSP Handler, we must edit the mod_python configuration which you can find in /etc/httpd/conf.d/python.conf. This file contains many examples - we make a backup of it and create that file again from scratch. I'm using the default Fedora/CentOS document root /var/www/html here in the <Directory>directive - adjust this to your needs. The important lines are AddHandler mod_python .py and PythonHandler mod_python.psp: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 .psp PythonHandler mod_python.psp PythonDebug On </Directory> |
Restart Apache afterwards:
/etc/init.d/httpd restart
Now we create a little PSP test script (e.g. /var/www/html/test.psp) with HTML and Python code in it...
vi /var/www/html/test.psp
<html> <body> <h1><% req.write("Hello!") %></h1> </body> </html> |
相关文章推荐
- linux下 Apache mysql python mod_python Django 配置安装说明,绝对可以安装上的说明
- fedora18下的opencv-2.4.5安装记录+在python搭建opencv环境
- Python3.3.0+apache2.4.4+django1.5.4+mod_wsgi3.4安装
- python 安装第三方mod
- apache mod_python 安装
- Centos5配置Python mod_wsgi Django安装osqa
- python+apache+mod_python+django 编译安装指南[转]
- Fedora19下opencv和python-opencv安装测试
- apache+python+mod_python+django 编译安装指南
- apache,python,mod_wsgi,django,mysql在linux下的安装
- Fedora15编译安装Python3.2.1
- mod_python模块安装
- centos64位,apache2,python2.5,django,mod_python平台安装配置。
- mod_python安装及问题解决
- Fedora18下opencv-2.4.5安装记录+并在python搭建opencv环境
- linux下安装mod_python遇到的问题
- Fedora 19安装LAMP(Linux+Apache+Mysql+Perl/PHP/Python)
- fedora17 安装Python和eclipse简单方法
- fedora下的ganglia安装、配置,以及python模块的扩展
- linux+apache+php+fastcgi+mod_python安装流水帐