2015-05-11 130 views
0

我似乎無法理解爲什麼Djjango/apache拒絕加載DJANGO_SETTINGS_MODULE,儘管它已被聲明! 我檢查到環境變量是通過python加載的,並且manage.py可以創建一個運行服務器,而不會出現有關設置的任何錯誤。django停止使用mod_wsgi/apache

echo $DJANGO_SETTINGS_MODULE >>> harshp.settings.production 

Apache的錯誤日誌

AH02282: No slotmem from mod_heartmonitor 
AH00489: Apache/2.4.12 (Unix) OpenSSL/1.0.1k mod_wsgi/3.5 Python/2.7.6 configured -- resuming normal operations 
AH00094: Command line: '/opt/bitnami/apache2/bin/httpd -f /opt/bitnami/apache2/conf/httpd.conf' 
mod_wsgi (pid=7056): Exception occurred processing WSGI script '/opt/bitnami/apps/django/django_projects/harshp.com/harshp/wsgi.py'. 
Traceback (most recent call last): 
File "/opt/bitnami/python/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 170, in __call__ 
self.load_middleware() 
File "/opt/bitnami/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 49, in load_middleware 
for middleware_path in settings.MIDDLEWARE_CLASSES: 
File "/opt/bitnami/python/lib/python2.7/site-packages/django/conf/__init__.py", line 48, in __getattr__ 
self._setup(name) 
File "/opt/bitnami/python/lib/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup 
% (desc, ENVIRONMENT_VARIABLE)) 
ImproperlyConfigured: Requested setting MIDDLEWARE_CLASSES, but settings are not configured. 
You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.~  

Apache的配置

WSGIScriptAlias//opt/bitnami/apps/django/django_projects/harshp.com/harshp.wsgi 
WSGIPythonPath /opt/bitnami/apps/django/django_projects/harshp.com 

<Directory /opt/bitnami/apps/django/django_projects/harshp.com/> 
Require all granted 
</Directory> 

wsgi.py

sys.path.append('/opt/bitnami/apps') 
sys.path.append('/opt/bitnami/apps/django/django_projects/harshp.com') 
*** edit *** SETTINGS was typed as SETTNGS only on SO 
os.environ['DJANGO_SETTINGS_MODULE']='harshp.settings.production' 
import django.core.handlers.wsgi 
application = django.core.handlers.wsgi.WSGIHandler()               

的httpd-app.conf

<IfDefine !IS_DJANGOSTACK_LOADED> 
    Define IS_DJANGOSTACK_LOADED             
    WSGIDaemonProcess wsgi-djangostack processes=2 threads=15 display-name=%{GROUP} 
</IfDefine> 

WSGIScriptAlias/'/opt/bitnami/apps/django/django_projects/harshp.com/harshp/wsgi.py' 

<Directory "/opt/bitnami/apps/django/django_projects/harshp.com/harshp/"> 
    WSGIProcessGroup wsgi-djangostack 
    WSGIApplicationGroup %{GLOBAL} 
    <IfVersion <2.3> 
     Order allow,deny 
     Allow from all 
    </IfVersion> 
    <IfVersion >= 2.3> 
     Require all granted 
    </IfVersion> 
</Directory> 
+0

與你的問題沒有關係,但是從內存來看,'Define'指令在Apache 2.2中不可用,所以在命令/允許指令中允許使用Apache 2.2是毫無意義的,因爲整個文件不能使用反正用Apache 2.2。 –

回答

1

bitnami developer here。我認爲你有一個錯字,至少在代碼中要粘貼:

os.environ['DJANGO_SETTNGS_MODULE']='harshp.settings.production' 

你可以嘗試將其從處理設定改爲設置?

+0

這是一個拼寫錯誤,我糾正了它。 – kicker86