Skip to content Skip to sidebar Skip to footer

Cannot Deploy Django On Apache With Mod-wsgi

I have been working on a Django app that I am ready to move to the production server. I have Apache and mod_wsgi installed and I used a test to check to see that it all works, and

Solution 1:

I will share how I've configured a simple example:

import os,sys
apache_configuration = os.path.dirname(__file__)
project = os.path.dirname(apache_configuration)
workspace = os.path.dirname(project)
sys.path.append(workspace)
sys.path.append('PATH TO YOUR PROJECT ROOT')

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

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

On your VirtualHost directive on Apache config you must have:

WSGIScriptAlias / /PATH/TO/YOUR/.wsgi

Example:

<VirtualHost *:80>
    ErrorLog /home/user/logs/error.log
    ...
    WSGIScriptAlias / /PATH/TO/YOUR/.wsgi
    ...
</VirtualHost>

Post a Comment for "Cannot Deploy Django On Apache With Mod-wsgi"