2012-09-13 46 views
2

虛擬環境中我創建了一個名爲「pyapps」和it.I've安裝pinax和Django的virtualenv中安裝了Apache 2和mod_wsgi.I創建了一個名爲「apache」目錄裏面我Django項目(testproject),並把「django.wsgi」文件directory.Here裏面是我的WSGI文件的內容:阿帕奇沒有得到進入設立Django項目

import os 
import sys 

# put the Django project on sys.path 
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../../"))) 

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

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

然後創建一個目錄「/check/www」,並把我的項目文件夾,裏面「/check/wwwpyapps文件夾'我在/check/www上修了777。

最後,我創建了一個虛擬主機,它的內容如下:

<VirtualHost *:80> 
    ServerAdmin myemail 
    ServerName djangoserver 

    WSGIDaemonProcess textpisodes user=rajat threads=10 python-path=/check/www 
    WSGIProcessGroup textpisodes 

    WSGIScriptAlias//check/www/textpisodes/apache/django.wsgi 
    <Directory /check/www/textpisodes/apache> 
     Order deny,allow 
     Allow from all 
    </Directory> 

    ErrorLog /var/log/apache2/error.log 
    LogLevel warn 

    CustomLog /var/log/apache2/access.log combined 
</VirtualHost> 

現在,當我嘗試訪問的「http:// djangoserver」,所有我得到的是Internal Server Error。這裏是內容我的apache日誌文件。

[Thu Sep 13 18:39:51 2012] [error] [client 127.0.0.1] mod_wsgi (pid=4890): Target WSGI script '/check/www/textpisodes/apache/django.wsgi' cannot be loaded as Python module. 
[Thu Sep 13 18:39:51 2012] [error] [client 127.0.0.1] mod_wsgi (pid=4890): Exception occurred processing WSGI script '/check/www/textpisodes/apache/django.wsgi'. 
[Thu Sep 13 18:39:51 2012] [error] [client 127.0.0.1] Traceback (most recent call last): 
[Thu Sep 13 18:39:51 2012] [error] [client 127.0.0.1] File "/check/www/textpisodes/apache/django.wsgi", line 9, in <module> 
[Thu Sep 13 18:39:51 2012] [error] [client 127.0.0.1]  import django.core.handlers.wsgi 
[Thu Sep 13 18:39:51 2012] [error] [client 127.0.0.1] ImportError: No module named django.core.handlers.wsgi 

回答

2

您需要添加您的虛擬環境路徑,以便apache/python可以在其中找到模塊。

要麼把這個在你的Apache配置(外VirtualHost項)

WSGIPythonPath /home/me/virtualenv/env1/lib/python2.7/site-packages 

或者把它放在sys.path在WSGI文件。

+0

現在我得到'錯誤地配置:導入中間件pinax.apps.account.middleware時出錯:「無法導入名稱utils''.Any Ideas? – rayn