ubuntu 安装 apache2.2+mod_wsgi+Django

ubuntu  安装 apache2.2+mod_wsgi+Django

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

1,Ubuntu更新系统

sudo apt-get update
sudo apt-get upgrade

2,安装apache,mod_wsgi,Django

sudo apt-get install apache2 libapache2-mod-wsgi  python-django

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

3,配置Django环境

sudo mkdir  /opt/wwwroot

cd /opt/wwwroot
sudo django-admin startproject hello

    创建wsgi文件

sudo mkdir /opt/wwwroot/hello/apache
sudo gedit /opt/wwwroot/hello/apache/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站点

sudo gedit /etc/apache2/sites-available/hello
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信息解析该域名。

sudo gedit /etc/hosts
新增一行hosts记录
172.0.0.1   hello.com

   激活hello站点

sudo a2ensite hello
sudo service apache2 reload

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

本条目发布于2013年5月10日。属于简单配置开发环境分类,被贴了apache2.2Djangomod_wsgiUbuntu 标签。

转自:http://www.pianai.net/?p=11

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值