您的位置:首页 > 运维架构 > Apache

redhat下安装apache+python+mod_python+django

2013-02-04 12:39 471 查看
点击打开链接

用惯了ubuntu,才知道redhat有点坑爹哦,安装mod_python如此繁琐。

1、安装apache
(1)wget http://www.fayea.com/apache-mirror//httpd/httpd-2.2.22.tar.gz (2)tar -zvxf httpd-2.2.22.tar.gz
(3)cd httpd-2.2.22
(4) ./configure --prefix=/opt/apache --with-config-file-path=/opt/apache/conf  --enable-mods-shared=most --enable-track-vars --enable-cgi --enable-so --enable-file-cache --enable-disk-cache
--enable-cache --enable-mem-cache --enable-dumpio --enable-logio --enable-mime-magic --enable-headers --enable-usertrack --enable-version --enable-ssl --enable-http --enable-rewrite --enable-proxy --enable-proxy-connect --enable-proxy-http --enable-proxy-ftp
--enable-proxy-ajp --enable-proxy-balancer 

(5)make
(6)make install

成功安装后执行/opt/apache/bin/apachectl start然后curl "http://127.0.0.1" 或者在浏览器输入“[b]http://ip”,可以访问到<html><body><h1>It
works!</h1></body></html>内容。[/b]

2、安装python2.7
(1)wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz (2)tar -zvxf Python-2.7.3.tgz
(3)cd Python-2.7.3
(4)./configure --prefix=/opt/python/2.7 --enable-shared (--enable-shared是为了后面安装mod-python而设置的)
(5)make
(6)make install

成功安装后可以通过/opt/python/2.7/bin/python2.7进入python控制台。
【如果运行python程序时报以下错误/opt/python/2.7/bin/python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory,需求做如下操作:vi /etc/ld.so.conf.d/python2.7.conf--》写入/opt/python/2.7/lib并保存--》ldconfig,然后重新运行/opt/python/2.7/bin/python2.7就可以了。】

3、安装 mod_python
(1)wget http://archive.apache.org/dist/httpd/modpython/mod_python-3.3.1.tgz (2)tar -zvxf mod_python-3.3.1.tgz
(3)cd mod_python-3.3.1
(4)./configure --with-apxs=/opt/apache/bin/apxs --with-python=/opt/python/2.7/bin/python2.7
(5)make
(6)make install_dso
(7)make install_py_lib

成功安装后会在/opt/apache/modules目录下生成mod_python.so,在/opt/python/2.7/lib/python2.7/site-packages目录下生成mod_python目录及mod_python-3.3.1-py2.7.egg-info文件。

如果make的时候报以下错误:

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[1]: Leaving directory `/usr/src/dev/mod_python-3.3.1/src'
make: *** [do_dso] Error 2
则需要修改一下src/
connobject.c将其中的
!(b == APR_BRIGADE_SENTINEL(b)改为!(b == APR_BRIGADE_SENTINEL(bb),保存后重新执行make就好了。



4、安装Django
(1)wget http://www.djangoproject.com/m/releases/1.3/Django-1.3.1.tar.gz (2)cd Django-1.3.1
(3)/opt/python/2.7/bin/python2.7 setup.py install

成功安装的话会在/opt/python/2.7/lib/python2.7/site-packages目录下生成django目录及Django-1.3.1-py2.7.egg-info文件。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: