python mod,mod_python的安装

该博客介绍了如何在Linux环境中安装Python 2.5,特别是在x86-64系统下,并详细阐述了如何配置和编译mod_python模块以与Apache2集成,包括修改源文件、编译选项以及配置httpd.conf文件。同时,还提供了创建Python2.5别名和设置动态库路径的步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

版本要求:

python Python-2.5.4.tgz   (关于这一步,有好多linux环境下已经有python啦,可以不用安装, 一般python在/usr/bin这个目录下)

mod_python mod_python-3.3.1

apache

2. mod_python 的源文件要做修改,不然编译不过  (这个是一定要改的)

src/connobject.c 的 142 行,改成

//!(b == APR_BRIGADE_SENTINEL(b) ||

!(b == APR_BRIGADE_SENTINEL(bb) ||

3. 开始编译

./configure --with-apxs=/www/apache2/bin/apxs --with-python=/usr/bin/python

make

make install

编辑httpd.conf

Alias /liuy  "/home/liuy/public_html"

Options FollowSymLinks

AllowOverride None

Order allow,deny

Allow from all

#        SetHandler mod_python

AddHandler mod_python .py

PythonHandler mod_python.publisher

PythonDebug On

测试:

在/home/liuy/public_html 目录下新建一个test.py

#coding:gb2312

def index(req):

req.write("hello,world!")

return

在x86-64下的安装:

安装python2.5(不影响原来python2.4.3)

# tar -xvfz Python-2.5.tgz

# cd Python-2.5

配置Python安装参数,不影响系统原有2.4.3环境

安装目录/opt/python2.5 启用线程 启用共享

# ./configure --prefix=/opt/python2.5 --with-threads --enable-shared

# make

# make install

创建别名

# vi /root/.bash_profile

在最后一行添加

alias python='/opt/python2.5/bin/python'

# source /root/.bash_profile

添加/usr/bin/python2.5符号连接

# ln -s /opt/python2.5/bin/python /usr/bin/python2.5

配置ld查找python2.5动态库

# vi /etc/ld.so.conf.d/opt-python2.5.conf

添加/opt/python2.5/lib后保存

/opt/python2.5/lib

更新动态库目录

# ldconfig

将python2.5动态库copy到/usr/lib

# cp /opt/python2.5/lib/libpython2.5* /usr/lib

# tar -xvzf mod_python-3.3.1.tgz

# cd mod_python-3.3.1

# ./configure --with-apxs=/usr/sbin/apxs --with-python=/opt/python2.5/bin/python

# make

# make install

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值