CentOS 安装mod_python
1.初始环境安装
httpd相关的RPM包版本号:
httpd-2.2.3-63.el5.centos.1
httpd-devel-2.2.3-63.el5.centos.1
apr-1.2.7-11.el5_3.1
apr-devel-1.2.7-11.el5_3.1
apr-util-1.2.7-11.el5
apr-util-devel-1.2.7-11.el5
2.编译python 2.7
./configure -enable-shared
wget http://www.python.org/ftp/python/2.7/Python-2.7.tar.bz2
tar jfvx Python-2.7.tar.bz2
cd Python-2.7
./configure -enable-shared
make all
make install
make clean
make distclean
----------------------------------------
默认有装python 2.4,进行以下操作
mv /usr/bin/python /usr/bin/python-bak
ln -s /usr/local/bin/python2.7 /usr/bin/python
sed -i 's/#!\/usr\/bin\/python/#!\/usr\/bin\/python2.4/g' /usr/bin/yum
------------------------------------------
安装完成后,执行python应该不成功,错误信息为:
/usr/local/bin/python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory
解决方案:
vim /etc/ld.so.conf
加入新的一行:
/usr/local/lib
然后执行:
/sbin/ldconfig
/sbin/ldconfig -v
3.安装mod_python-3.3.1
第一步:./configure --with-apxs=/usr/sbin/apxs
第二步:
vi src/connobject.c
修改
!(b == APR_BRIGADE_SENTINEL(b) ||
为
!(b == APR_BRIGADE_SENTINEL(bb) ||
第三步:
make
第四步:
make install
安装完成后在目录 /usr/lib64/httpd/modules
查看是否存在
mod_python.so
参考:
http://stackoverflow.com/questions/7880454/python-executable-not-finding-libpython-shared-library
http://hi.baidu.com/iwater707/item/34b71827e08487150975081d
http://bbs.chinaunix.net/thread-1198737-1-1.html
http://linux.chinaitlab.com/set/852148.html
http://www.360doc.com/content/12/0322/18/6938655_196712249.shtml