Ubuntu apache2下建立django开发环境
1. 安装djando
sudo apt-get install python-django
2. 安装mod_wsgi
sudo apt-get install libapache2-mod-wsgi sudo a2enmod wsgi//验证是否成功安装
3. apache配置文件
httpd.conf:
WSGIScriptAlias / /home/gby/workspace/mysite/mysite/django.wsgi
<Directory /home/gby/workspace/mysite/mysite>
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>
django.wsgi:
import os
import sys
path = '~/worksapce/mysite/'
if path not in sys.path:
sys.path.append(path)
os_environment['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
4. 其余工作
现在,enable你的django site并重启apache2
sudo service apache2 restart
a2enmod wsgi a2dissite default