django stopped working with mod_wsgi/apache
Question: I can't seem to understand why django/apache refuses to load
DJANGO_SETTINGS_MODULE inspite of it being declared! I checked that the
environmental variable is loaded through python, and manage.py can create a
run server without any errors about the settings.

    
    
    echo $DJANGO_SETTINGS_MODULE >>> harshp.settings.production
    

Apache error log

    
    
    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 config

    
    
    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>
    


Answer: bitnami developer here. I think you have a typo, at least in the code you are
pasting:

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

Can you try to change it from SETTNGS to SETTINGS?

