apache利用mod_python整合django
2012-09-11 18:13
351 查看
安装所需要的源码包:
• Apache 2.2.22 (http://labs.mop.com/apache-mirror//httpd/httpd-2.2.22.tar.gz)
• Python 2.7.3 (http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz)
• Mod_python 3.3.1 (http://archive.apache.org/dist/httpd/modpython/mod_python-3.3.1.tgz)
• Django 1.4 (https://www.djangoproject.com/download/1.4.1/tarball/)
安装步骤
1. Apache安装
#tar -zxvf httpd-2.2.22.tar.gz
# httpd-2.2.22
# ./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite
#make && make install
2. Python安装
# tar -zxvf Python-2.7.3.tgz
#cd Python-2.7.3
# ./configure
#make && make install
#mv /usr/bin/python /usr/bin/python.bak
#ln -s /usr/local/bin/python2.7 /usr/bin/python
#python -V #版本显示2.7.3
3. django安装
# tar -zxvf Django-1.4.1.tar.gz
#cd Django-1.4.1
#python setup.py install #执行没有报错,就说明安装成功
也可以检查是否成功
#python
>> import django #这样import导入django模块没有报错,就安装成功
4. mod_python安装
# tar -zxvf mod_python-3.3.1.tgz
# cd mod_python-3.3.1
#./configure \
--with-apxs=/usr/local/apache2/bin/apxs \
--with-python=/usr/local/bin/python2.7
#make #执行make的时候会报错,如下: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 `/root/django_python/mod_python-3.3.1/src'
make: *** [do_dso] Error 2
解决办法:
编辑 /$home/mod_python-3.3.1/src/connobject.c 的 142 行:
!(b == APR_BRIGADE_SENTINEL(b)
改成:
!(b == APR_BRIGADE_SENTINEL(bb) 即:改成两个b
#make clean
#make && make install
5. Apache conf配置
1>.配置下httpd.conf,在这个文件里添加
LoadModule python_module modules/mod_python.so
另外我是开启了vhosts里面配置的,只需要将这行前面的#去掉
Include conf/extra/httpd-vhosts.conf
接着就是配置httpd-vhosts.conf文件,如下:
<VirtualHost *:80>
ServerName www.test.com
DocumentRoot "/data0/django/mysite"
<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonAutoReload Off
PythonDebug Off
PythonPath "['/data0/django/mysite'] + sys.path"
PythonInterpreter mysite
</Location>
<Directory "/data0/django/mysite">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
重启apache,测试下。
大致就是这样的,你可以访问下面网址,有相关的资料:
http://blog.163.com/zhulp0372@yeah/blog/static/115894479201182134911490/ http://www.cnblogs.com/oubo/archive/2012/04/06/2434961.html http://djangobook.py3k.cn/2.0/chapter12/
• Apache 2.2.22 (http://labs.mop.com/apache-mirror//httpd/httpd-2.2.22.tar.gz)
• Python 2.7.3 (http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz)
• Mod_python 3.3.1 (http://archive.apache.org/dist/httpd/modpython/mod_python-3.3.1.tgz)
• Django 1.4 (https://www.djangoproject.com/download/1.4.1/tarball/)
安装步骤
1. Apache安装
#tar -zxvf httpd-2.2.22.tar.gz
# httpd-2.2.22
# ./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite
#make && make install
2. Python安装
# tar -zxvf Python-2.7.3.tgz
#cd Python-2.7.3
# ./configure
#make && make install
#mv /usr/bin/python /usr/bin/python.bak
#ln -s /usr/local/bin/python2.7 /usr/bin/python
#python -V #版本显示2.7.3
3. django安装
# tar -zxvf Django-1.4.1.tar.gz
#cd Django-1.4.1
#python setup.py install #执行没有报错,就说明安装成功
也可以检查是否成功
#python
>> import django #这样import导入django模块没有报错,就安装成功
4. mod_python安装
# tar -zxvf mod_python-3.3.1.tgz
# cd mod_python-3.3.1
#./configure \
--with-apxs=/usr/local/apache2/bin/apxs \
--with-python=/usr/local/bin/python2.7
#make #执行make的时候会报错,如下: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 `/root/django_python/mod_python-3.3.1/src'
make: *** [do_dso] Error 2
解决办法:
编辑 /$home/mod_python-3.3.1/src/connobject.c 的 142 行:
!(b == APR_BRIGADE_SENTINEL(b)
改成:
!(b == APR_BRIGADE_SENTINEL(bb) 即:改成两个b
#make clean
#make && make install
5. Apache conf配置
1>.配置下httpd.conf,在这个文件里添加
LoadModule python_module modules/mod_python.so
另外我是开启了vhosts里面配置的,只需要将这行前面的#去掉
Include conf/extra/httpd-vhosts.conf
接着就是配置httpd-vhosts.conf文件,如下:
<VirtualHost *:80>
ServerName www.test.com
DocumentRoot "/data0/django/mysite"
<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonAutoReload Off
PythonDebug Off
PythonPath "['/data0/django/mysite'] + sys.path"
PythonInterpreter mysite
</Location>
<Directory "/data0/django/mysite">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
重启apache,测试下。
大致就是这样的,你可以访问下面网址,有相关的资料:
http://blog.163.com/zhulp0372@yeah/blog/static/115894479201182134911490/ http://www.cnblogs.com/oubo/archive/2012/04/06/2434961.html http://djangobook.py3k.cn/2.0/chapter12/
相关文章推荐
- apache利用mod_python整合django
- linux下 Apache mysql python mod_python Django 配置安装说明,绝对可以安装上的说明
- Windows下Apache+mod_python+Django配置
- Debian+Django1.11+Apache2.4+mod_wsgi+python2.7搭建服务器
- 通过mod_python配置运行在Apache上的Django框架
- linux+django+apache+mod_wsgi+eclipse+python2.7 环境的搭建
- 在windows下使用apache与mod_python来集成django
- 利用mod_proxy实现Apache和Tomcat整合负载均衡
- [学习] Apache + mod_python + Django Step by Step
- Django+apache+python+mod_python的环境搭建
- python&Django&mariadb&Apache&mod_wsgi 环境部署
- 用mod_python在Apache上部署Django
- linxu下的apache+mod_python的djangoweb开发配置
- [python web]linux下apache + django + mod_wsgi + sqlite3配置
- mysql+apache+python+mod_python+MySQLdb+django环境安装(转)
- apache+python+mod_python+django 编译安装指南
- 用Apache 和mod_python部署Django
- ubuntu下配置django+apache+mysql+mod_python+Python
- windows下安装apache2.2 + python2.7 + django(mod_wsgi集成)
- django1.77+mod_wsgi+python2.79+apache2.24 在阿里云centos部署攻略