一 、安装APACHE2.2 (这个很简单,这里不做说明)
二、 python 2.5
1、编译安装
到 www.python.org 下载最新的 python 源码包,解压得到目录,进入该目录,执行:
# ./configure --prefix=/usr/local/python2.5
# make
# make install
使用下面命令将 python 添加到 /usr/bin 中,并且区别其他版本的 python 执行文件,使它们可以共存
# ln /usr/local/python2.5 /bin/python /usr/bin/python2.5
以后可以将新版本的 python 编译到 /opt/python/[版本]中,使用上面命令生成对应版本的链接。
2、设置运行命令
这里需要注意一下执行程序,现在的 python 2.5 的执行程序是 python2.5 ,
如果想进入 python 2.5 的 shell,需要键入 python2.5,
如果想系统使用 python 2.5 执行 .py 脚本,需要在脚本第一行将 python 运行命令修改为:
#!/usr/bin/python2.5
如果你觉得以后默认使用 python 2.5 就好,那么可以:
# rm -f /usr/bin/python
# ln /usr/local/python2.5/python /bin/python /usr/bin/python
这样执行 python 进入的就是 2.5 了。
三、安装mod_python-3.3.1.tgz
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/python2.5/bin/python
make
make install
可能出现下面的情况,按照下面的处理就行了
Fails to build with the following error from macports:
/opt/local/share/apr-1/build/libtool --silent --mode=compile /usr/bin/gcc-4.0 -prefer-pic -O2 -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -no-cpp-precomp -I/opt/local/include -I/opt/local/apache2/include -I/opt/local/include/apr-1 -I/opt/local/include/apr-1 -I/opt/local/include -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_www_mod_python/work/mod_python-3.3.1/src/include -I/opt/local/apache2/include -I/opt/local/Library/Frameworks/Python.framework/Versions/2.4/include/python2.4 -c -o connobject.lo connobject.c && touch connobject.slo connobject.c: In function '_conn_read':
connobject.c:142: error: request for member 'next' in something not a structure or union
apxs:Error: Command failed with rc=65536
.
make[1]: *** [mod_python.so] Error 1
make: *** [do_dso] Error 2
Error: Status 1 encountered during processing.
Bug reported at:
http://trac.macports.org/ticket/15791
http://bugs.gentoo.org/show_bug.cgi?id=230211
Recommended fix:
You can download the source and implement a suggested fix - on line 142 of
connobject.c you can replace
!(b == APR_BRIGADE_SENTINEL(b) ||
with
!(b == APR_BRIGADE_SENTINEL(bb) ||
suggested here:
http://www.mail-archive.com/dev@apr.apache.org/msg20588.html
However this is obviously untested, though it compiles fine.
(From response #6 from Gentoo bug report)