2013-08-17 43 views
0

即時通訊新的部署和我一直在試圖部署我的django應用程序,我似乎只能得到默認:"it works"頁面工作。我遵循了幾個教程,沒有運氣。 我'/etc/apache2/sites-available/37.***.22.**'虛擬主機:我該如何解決apache的django的默認apache頁面

`<VirtualHost *:80> 
      ServerAdmin [email protected]***.22.** 
      ServerName 37.***.22.** 
      DocumentRoot /var/www/37.***.22.**/public_html 
      <Directory /> 
        Options FollowSymLinks 
        AllowOverride None 
      </Directory> 
      <Directory /var/www/37.***.22.**/public_html> 
        Options Indexes FollowSymLinks MultiViews 
        AllowOverride None 
        Order allow,deny 


allow from all 
    </Directory> 

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ 
    <Directory "/usr/lib/cgi-bin"> 
      AllowOverride None 
      Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny 
      Allow from all 
    </Directory> 

    ErrorLog ${APACHE_LOG_DIR}/error.log 

    # Possible values include: debug, info, notice, warn, error, crit, 
    # alert, emerg. 
    LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined 

Alias /doc/ "/usr/share/doc/" 
<Directory "/usr/share/doc/"> 
    Options Indexes MultiViews FollowSymLinks 
    AllowOverride None 
    Order deny,allow 
    Deny from all 
    Allow from 127.0.0.0/255.0.0.0 ::1/128 
</Directory> 

WSGI文件:

import os 
import sys 
import site 

# Add the site-packages of the chosen virtualenv to work with 
site.addsitedir('~/.virtualenvs/myprojectenv/local/lib/python2.7/site-packages') 

# Add the app's directory to the PYTHONPATH 
sys.path.append('~/MyProject/django-bookmarks') 
sys.path.append('~/MyProject/django-bookmarks/django_bookmarks') 

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

# Activate your virtual env 
activate_env=os.path.expanduser("~/.virtualenvs/myprojectenv/bin/activate_this.$ 
execfile(activate_env, dict(__file__=activate_env)) 

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

我已經SCP'ed我的文件,我djagno應用到服務器上的目錄MyProject的。 我也跑了a2ensite 37.***.22.25並重新啓動apache,但即使如此,我仍然得到「它有效」的默認頁面。我該如何解決這個問題? 我也安裝了Postfgress。我真的很想部署這個應用程序,並一直在掙扎,並同時學習很多!任何建議將不勝感激。 在此先感謝。

+0

我看不出這是如何工作的。您沒有設置mod_wsgi或引用您的wsgi腳本的任何內容。如果你看到一個Django頁面,那一定是因爲其他配置。 –

+0

我沒有看到django頁面,它只是默認的apache頁面。我如何設置引用我的wsgi腳本或設置mod_wsgi?即時通訊非常新 – kenneth

+0

您是否閱讀並遵循Django文檔站點上的完美部署說明? –

回答

0

確保您已安裝並啓用了Apache的mod_wsgi

您還需要確保爲虛擬主機定義了WSGIProcessGroup和WSGIScriptAlias(mod_wsgi的configuration directives)。

+0

您鏈接到的博客文章僅討論爲Apache設置虛擬主機。如果我們假設Apache配置正確,那麼下一步就是獲得mod_wsgi(允許Apache和Django爲您的虛擬主機配置「互相」交談)。回顧如何使用WSGIProcessGroup和WSGIScriptAlias ...這些在您的原始文章中都缺少虛擬主機配置。 –

+0

謝謝,我給了我自己的時間,並通過django部署說明,並添加了WSGIScriptAlias和WSGIProcessGroup,我的應用程序現在部分工作。儘管我在URL中遇到了一些問題,但是我可以通過輸入來移動到我的應用的各個頁面。 myIP/django-bookmarks/login或myIP/django-bookmarks/register .....但是,當我點擊本身的標籤時,它會將我帶到myIP/register(沒有'django-bookmarks'),然後說:「在這個服務器上找不到URL」。試圖找出我在哪裏搞砸 – kenneth

相關問題