[英]unable to deploy Django on ubuntu with apache mod WSGI
我正在使用ubuntu 12.04,並且執行了以下操作:
須藤apt-get install python-mysql
sudo python setup.py install(安裝Django 1.6.2)
須藤apt-get install mysql-server -...
須藤apt-get install apache2
須藤apt-get install libapache2-mod-wsgi
這是我的配置文件:
/home/firstweb.wsgi:
import os
import sys
sys.path = ['/var/www/firstweb'] + sys.path
os.environ['DJANGO_SETTINGS_MODULE'] = 'firstweb.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
/etc/apache/sites-availables/firstweb.conf:
<VirtualHost *:80>
WSGIScriptAlias / /home/adel/firstweb.wsgi
ServerName firstweb.com
Alias /static /var/www/firstweb/static/
<Directory /var/www/firstweb/>
order allow,deny
Allow from all
</Directory>
</VirtualHost>
然后我做了:
a2ensite firstweb.conf
cd /var/www/
django-admin.py startproject firstweb
apachectl restart
vi /etc/hosts
並添加以下內容( 192.168.0.123
是我的wlan ip)
192.168.0.123 firstweb.com
我使用mysql並創建數據庫並更改settings.py
, syncdb
正常運行
但是,當我在瀏覽器中輸入www.firstweb.com時,將顯示Apache的默認頁面(有效。。。)
並且Django默認頁面沒有出現!
我的配置有什么問題?
謝謝。
您的虛擬服務器不在www.firstweb.com上監聽,而僅在firstweb.com上監聽。 您應該為www版本添加ServerAlias指令。
WSGIScriptAlisa指令所引用的路徑不在您為Directory指令指定的任何目錄中,該目錄指示允許Apache從何處提供文件/腳本。 此外,Apache用戶通常將無法訪問用戶主目錄下的文件。 這兩個問題都會導致不同的“禁止的HTTP”響應。 因此,即使您解決了ServerName / ServerAlias和主機問題,也很可能會遇到這些問題。 確保您閱讀了Django網站上的官方mod_wsgi部署文檔。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.