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

ubuntu 13.04 安装 apache2.2+mod_wsgi+Django

2013-09-29 08:34 417 查看


超简单系列:ubuntu 13.04 安装 apache2.2+mod_wsgi+Django


超简单系列开发环境部署均用ubuntu系统内置安装包,技术有限未使用源代码编译最新版程式。


1,Ubuntu更新系统


2,安装apache,mod_wsgi,Django

更多Ubuntu系统内置安装包请搜索:Ubuntu Packages Search


3,配置Django环境


    创建wsgi文件


    文件django.wsgi贴入下面内容

django.wsgi内容
import os
import sys
sys.path.append('/opt/wwwroot')
sys.path.append('/opt/wwwroot/hello')
path = '/opt/wwwroot'

if path not in sys.path:
sys.path.insert(0, '/opt/wwwroot')

os.environ['DJANGO_SETTINGS_MODULE'] = 'hello.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()


4,创建一个新的apache站点

hello内容
<VirtualHost *:80>

ServerName hello.com
DocumentRoot /opt/wwwroot/hello

<Directory /opt/wwwroot/hello>
Order allow,deny
Allow from all
</Directory>
Alias /robots.txt /opt/wwwroot/hello/robots.txt
Alias /favicon.ico /opt/wwwroot/hello/favicon.ico
Alias /images /opt/wwwroot/hello/images
Alias /static /opt/wwwroot/hello/static

 WSGIDaemonProcess hello.com processes=2 threads=15 display-name=%{GROUP}
WSGIProcessGroup hello.com
WSGIScriptAlias / /opt/wwwroot/hello/apache/django.wsgi

 </VirtualHost>


   由于使用了域名hello.com,应新增一行hosts信息解析该域名。

新增一行hosts记录
172.0.0.1   hello.com


   激活hello站点


5,设置完毕打开浏览器进入输入hello.com,就可以看到Django欢迎界面了。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  django