ubuntu 安裝 apache2.2+mod_wsgi+Django

ubuntu  安裝 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歡迎界面了。

本條目發佈於2013年5月10日。屬於簡單配置開發環境分類,被貼了apache2.2Djangomod_wsgiUbuntu 標籤。

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章