django停止使用mod_wsgi / apache

时间:2015-05-11 13:52:40

标签: django apache mod-wsgi bitnami

我似乎无法理解为什么django / apache拒绝加载DJANGO_SETTINGS_MODULE,尽管它被声明! 我检查了环境变量是通过python加载的,manage.py可以创建一个运行服务器而没有任何关于设置的错误。

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>

1 个答案:

答案 0 :(得分:1)

bitnami开发者在这里。我认为你有一个拼写错误,至少在你粘贴的代码中是这样的:

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

您可以尝试将其从SETTNGS更改为SETTINGS吗?