mod_python安装及问题解决
2011-09-28 08:49
1241 查看
一、先下载一份最新版本的mod_python,当前最新版是3.3.1版:
wget http://apache.mirror.phpchina.com/httpd/modpython/mod_python-3.3.1.tgz
这里要注意,只有最新版本才支持2.2.2以上的apache。
二、解包,安装:
tar xzvf mod_python-3.3.1.tgz
cd mod_python-3.3.1
./configure --with-apxs=/usr/local/apache/bin/apxs --with-python=/usr/local/python251/bin/python --with-max-locks=32 --with-python-src=/soft/Python-2.5.1/ --with-flex=/usr/bin/flex
make
make install
在make install的过程中,有可能出问题,我就是在那一步卡住了,结果害我多折腾了半天,报错如下:
/usr/bin/install -c -d /usr/local/apache/modules
/usr/bin/install -c src/mod_python.so /usr/local/apache/modules
/usr/bin/install: stat‘src/mod_python.so’失败: 没有那个文件或目录
make[1]: *** [install_dso] 错误 1
make[1]: Leaving directory `/soft/mod_python-3.3.1'
make[1]: Entering directory `/soft/mod_python-3.3.1'
cd dist && make install_py_lib
一开始还以为是mod_python和apache 2.2.2不兼容,在网上找资料找了半天,最后在mod_python官方网站找到这样一篇文章:
4.1. src/mod_python.so: No such file or directory
When running “make install” I get this:
# make install
[snip]
Performing DSO installation.
/usr/bin/install -c src/mod_python.so /usr/local/apache2/modules
/usr/bin/install: cannot stat `src/mod_python.so’: No such file or directory
make[1]: *** [install_dso] Error 1
make[1]: Leaving directory `/home/hobb/mod_python-3.0.1′
make: *** [install] Error 2
#
This is a problem with libtool. Apache comes with its own copy of libtool, and the version which comes with Apache 2.0.43 is old for some reason. To fix this problem, you need to first make sure that you a have a recent libtool (”libtool –version” should show
1.4.2 or later), then recompile Apache by first rerunning ./buildconf like this:
$ ./buildconf
$ ./configure –your-config-args
$ make clean ; make
$ make install
And finally rebuild mod_python with
$ ./configure
$ make clean ; make
文章上说是libtool版本太旧的原因,他们给出的解决方案是:重新编译apache,当时我脑子也没有转过弯来,傻乎乎地直接照着他们说的重新编译,折腾半天,问题依旧,只好继续Google,最后在一个法文站点上看到了一个让我差点当场崩溃的答案,最简单的方法是这样的:
mv /usr/local/apache/build/libtool /usr/local/apache/build/libtool.old
ln -s /usr/bin/libtool /usr/local/apache/build/libtool
方才明白,自己走了多少弯路,其实只要link一下libtool就可以了!看来mod_python的官方网站也该检讨一下他们的文档了!当然,由此得出的教训也很深刻,那就是:谨慎求解,别急于求成!
三、配置httpd.conf,使之支持python程序。
cd /usr/local/apache/conf
vi httpd.conf
添加:
LoadModule python_module modules/mod_python.so
创建一个虚拟主机:
AllowOverride All
Options Indexes Foll
4000
owSymlinks MultiViews
Order allow,deny
Allow from all
ServerAdmin webmaster@handaoliang.cn
DocumentRoot /home/handaoliang/web/python
ServerName www.handaoliang.cn
ErrorLog logs/handaoliang_cn-error_log
CustomLog logs/handaoliang_cn-access_log common
然后,在此虚拟主机上加上如下三行代码:
SetHandler mod_python
PythonHandler mod_python.publisher
PythonDebug On
完成后是这个样子:
AllowOverride All
Options Indexes FollowSymlinks MultiViews
Order allow,deny
Allow from all
#允许执行python程序
SetHandler mod_python
PythonHandler mod_python.publisher
PythonDebug On
ServerAdmin webmaster@handaoliang.cn
DocumentRoot /home/handaoliang/web/python
ServerName www.handaoliang.cn
ErrorLog logs/handaoliang_cn-error_log
CustomLog logs/handaoliang_cn-access_log common
写一个脚本,测试一下:
def index():
return "Welcome
to handaoliang.cn"
如果一切正常,当访问http://www.handaoliang.cn时,应该会显示:Welcome to handaoliang.cn的字样。
参考资料:
Mod_python Manual:http://www.modpython.org/live/current/doc-html/
转自:http://www.handaoliang.com/article_33.html
wget http://apache.mirror.phpchina.com/httpd/modpython/mod_python-3.3.1.tgz
这里要注意,只有最新版本才支持2.2.2以上的apache。
二、解包,安装:
tar xzvf mod_python-3.3.1.tgz
cd mod_python-3.3.1
./configure --with-apxs=/usr/local/apache/bin/apxs --with-python=/usr/local/python251/bin/python --with-max-locks=32 --with-python-src=/soft/Python-2.5.1/ --with-flex=/usr/bin/flex
make
make install
在make install的过程中,有可能出问题,我就是在那一步卡住了,结果害我多折腾了半天,报错如下:
/usr/bin/install -c -d /usr/local/apache/modules
/usr/bin/install -c src/mod_python.so /usr/local/apache/modules
/usr/bin/install: stat‘src/mod_python.so’失败: 没有那个文件或目录
make[1]: *** [install_dso] 错误 1
make[1]: Leaving directory `/soft/mod_python-3.3.1'
make[1]: Entering directory `/soft/mod_python-3.3.1'
cd dist && make install_py_lib
一开始还以为是mod_python和apache 2.2.2不兼容,在网上找资料找了半天,最后在mod_python官方网站找到这样一篇文章:
4.1. src/mod_python.so: No such file or directory
When running “make install” I get this:
# make install
[snip]
Performing DSO installation.
/usr/bin/install -c src/mod_python.so /usr/local/apache2/modules
/usr/bin/install: cannot stat `src/mod_python.so’: No such file or directory
make[1]: *** [install_dso] Error 1
make[1]: Leaving directory `/home/hobb/mod_python-3.0.1′
make: *** [install] Error 2
#
This is a problem with libtool. Apache comes with its own copy of libtool, and the version which comes with Apache 2.0.43 is old for some reason. To fix this problem, you need to first make sure that you a have a recent libtool (”libtool –version” should show
1.4.2 or later), then recompile Apache by first rerunning ./buildconf like this:
$ ./buildconf
$ ./configure –your-config-args
$ make clean ; make
$ make install
And finally rebuild mod_python with
$ ./configure
$ make clean ; make
文章上说是libtool版本太旧的原因,他们给出的解决方案是:重新编译apache,当时我脑子也没有转过弯来,傻乎乎地直接照着他们说的重新编译,折腾半天,问题依旧,只好继续Google,最后在一个法文站点上看到了一个让我差点当场崩溃的答案,最简单的方法是这样的:
mv /usr/local/apache/build/libtool /usr/local/apache/build/libtool.old
ln -s /usr/bin/libtool /usr/local/apache/build/libtool
方才明白,自己走了多少弯路,其实只要link一下libtool就可以了!看来mod_python的官方网站也该检讨一下他们的文档了!当然,由此得出的教训也很深刻,那就是:谨慎求解,别急于求成!
三、配置httpd.conf,使之支持python程序。
cd /usr/local/apache/conf
vi httpd.conf
添加:
LoadModule python_module modules/mod_python.so
创建一个虚拟主机:
AllowOverride All
Options Indexes Foll
4000
owSymlinks MultiViews
Order allow,deny
Allow from all
ServerAdmin webmaster@handaoliang.cn
DocumentRoot /home/handaoliang/web/python
ServerName www.handaoliang.cn
ErrorLog logs/handaoliang_cn-error_log
CustomLog logs/handaoliang_cn-access_log common
然后,在此虚拟主机上加上如下三行代码:
SetHandler mod_python
PythonHandler mod_python.publisher
PythonDebug On
完成后是这个样子:
AllowOverride All
Options Indexes FollowSymlinks MultiViews
Order allow,deny
Allow from all
#允许执行python程序
SetHandler mod_python
PythonHandler mod_python.publisher
PythonDebug On
ServerAdmin webmaster@handaoliang.cn
DocumentRoot /home/handaoliang/web/python
ServerName www.handaoliang.cn
ErrorLog logs/handaoliang_cn-error_log
CustomLog logs/handaoliang_cn-access_log common
写一个脚本,测试一下:
def index():
return "Welcome
to handaoliang.cn"
如果一切正常,当访问http://www.handaoliang.cn时,应该会显示:Welcome to handaoliang.cn的字样。
参考资料:
Mod_python Manual:http://www.modpython.org/live/current/doc-html/
转自:http://www.handaoliang.com/article_33.html
相关文章推荐
- [Centos] mod_wsgi 安装流程以及遇到问题解决办法。apxs: command not found 或 Sorry, Python developer package does not appear to be installed.
- Python——解决Matplotlib安装问题
- 安装win32com报错-Python Version 2.7 required which was not found in the registry 问题解决 .
- python库numpy,scipy,matplotlib安装配置过程中遇到的问题及解决方法
- 解决python 自动安装缺少模块的问题
- sublime text3刚从官网下载安装后,Ctrl+B无法直接运行Python文件问题--解决方法
- CentOS 安装 opencv, 解决 Python cv2 module 问题
- Python 包安装error: Microsoft Visual C++ 14.0 is required...问题解决方案,
- 在Windows上安装Python+MySQL 的常见问题及解决方法
- Python安装模块出现问题UnicodeDecodeError的解决方法
- python中cx_Oracle模块安装遇到的问题与解决方法
- anaconda4.4.0 python3.6 安装opencv3 问题解决
- 如何解决python2.7x 版本的安装出错问题
- Ubuntu16.04下在Python2.7安装OpenCV3.2.0出现的问题与解决办法
- python 3.6下安装opencv 解决import cv2 问题
- python安装cx_Oracle模块常见问题与解决方法
- CentOS6.5安装exFAT时python3不兼容scons的问题的解决
- windows下安装python basemap时使用Visual Studio编译geos时遇到的问题以及解决方法
- 解决python中flask_sqlalchemy包安装失败的问题
- python MySQLdb在windows环境下的快速安装、问题解决方式