2013-10-17 30 views
0

我目前正在嘗試部署我的第一個基於django的站點,並且遇到了一些問題,因爲我配置服務器的經驗很少。在FastCGI模式下運行Django的ImportError

我按照主機提供的指南進行操作,現在我的文件看起來像這樣。

該文件夾結構。

mysite/ 
    manage.py 
    mysite/ 
     apps 
     settings/ 
      __init__.py 
      base.py 
      local.py 
      production.py 
    requirements.txt 
    venv 
www/ 
    .htaccess 
    mysite.fcgi 

的.htaccess

​​

mysite.fcgi

#!/usr/local/bin/python 
import sys 
import os 

sys.path.append("home/users/myuser") 

from django.core.handlers.wsgi import WSGIHandler 
from flup.server.fcgi import WSGIServer 

os.chdir("/home/users/myuser/mysite/") 
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' 

WSGIServer(WSGIHandler()).run() 

主機提供的資料說,他們正在運行的FastCGI,但在添加處理程序時。 htaccess我看到他們已經添加了fcgid腳本而不是fastcgi腳本。所以我都試過了。

當使用fcgid腳本我從錯誤日誌此錯誤:

mod_fcgid: stderr: ImportError: Could not import settings 'mysite.settings' 
(Is it on sys.path?): No module named mysite.settings 

當使用FastCGI的腳本我從錯誤日誌中出現此錯誤:

File does not exist: /home/users/myuser/www/mysite.fcgi/favicon.ico 

另外我使用virtualenv作爲我的項目,看起來像這樣。

requirements.txt

Django==1.4.2 
Markdown 
PIL=1.1.7 
MySQL-python 
South 
flup 

如果任何人都可以看到我在做什麼錯,幫助將非常感激。謝謝。

由於我使用的virtualenv我不得不把它添加到我的.fcgi文件來解決問題

venv = '/home/users/myuser/mysite/venv/bin/activate_this.py' 
execfile(venv, dict(__file__=venv)) 

回答

0

我不knwow有關FastCGI的很多,但似乎你在哪裏扔這第二個選項錯誤File does not exist: /home/users/myuser/www/mysite.fcgi/favicon.ico必須是Apache配置文件中的設置。 mysite.settings似乎是正確的,所以也許找到一種方法來刪除對.ico文件的引用(我在mod-WSGI上的django設置將在apache2配置中),或者將一個ico文件添加到它當前不能運行的路徑被發現。