在apache上面部署django应用
在前面的文章中介绍了django的一些部署方式。这里介绍django在apache上面的部署方式。
1.测试环境: mandriva 2009.0 + python2.5.2
2.安装mysql:urpmi MySQL MySQL-client
3.mysql-server的配置:注释skip-networking这一句在/etc/my.cnf
4.安装其它必要包:urpmi apache-mod_python
urpmi python-django python-mysql
python-django在urpm中已经集成可以直接安装,但是你也可以到django的官网去下载最新安装包。
5.配置apache:
mkdir /home/mycode
cd /home/mycode
/usr/bin/django-admin.py startproject mysite
cp /etc/httpd/modules.d/16_mod_python.conf /etc/httpd/modules.d/16_mod_python.conf_orig
cat /dev/null > /etc/httpd/modules.d/16_mod_python.conf
vi /etc/httpd/modules.d/16_mod_python.conf
在16_mod_python.conf中输入:
LoadModule python_module extramodules/mod_python.so
<Location “/mysite/”>
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonOption django.root /mysite
PythonDebug On
PythonPath “['/home/mycode/'] + sys.path”
</Location>
7.重启apache:service httpd restart
8.查看http://localhost/mysite即可。
9.查看80端口被占用:
netstat -anvp
lsof -i :80
Related posts:














