环境:ubuntu12.04 server | apache2 | django1.6 | python2.7 | mod_wsgi
1. 安装apache2:
sudo apt-get install apache2
2. 安装mod_wsgi.so:
2.x python:
sudo apt-get install libapache2-mod-wsgi
3. 安装Django1.6:
sudo pip install django
建立工程:
在/var/www下面建立工程(cd /var/www)
sudo django-admin.py startproject mysite
文件结构如下: mysite/ manage.py mysite/ __init__.py settings.py urls.py wsgi.py
4. 配置httpd.conf:
采用wsgi部署Django的详细过程可参考Django的官方网站(https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/modwsgi/)
在httpd.conf里加入:
WSGIScriptAlias / /var/www/mysite/mysite/wsgi.py WSGIPythonPath /var/www/mysite <Directory /var/www/mysite> <Files wsgi.py> Order deny,allow Allow from all </Files> </Directory>
5. 重启apache2:
sudo /etc/init.d/apache2 restart
修改apache.conf中的<Directory>
deny 为Allow from all