django on apache2 with mod_wsgi

Reference: https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/

Sitename: vkrm

Location: /work/vkrm

1. Install mod_wsgi (and Apache if not already). I had both already installed (I checked for mod_wsgi by running “yum install mod_wsgi”). If not, follow instructions on: http://code.google.com/p/modwsgi/wiki/InstallationInstructions

2. Enable “mod_wsgi” and httpd.conf

su -c vi /etc/httpd/conf/httpd.conf

Add line:

LoadModule wsgi_module modules/mod_wsgi.so

3. Create a static directory in your site. Inside the directory that contains “manage.py”, run:

mkdir static

4. Copy admin static files

python manage.py collectstatic
mv admin static

5. Create vkrm/apache/django.wsgi

import os import sys
sys.path.append('/work/')
sys.path.append('/work/vkrm')
os.environ['DJANGO_SETTINGS_MODULE'] = 'vkrm.settings'
import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler()

6. Edit httpd.conf. Add:

WSGIScriptAlias /vkrm /work/vkrm/apache/django.wsgi
<Directory /work/vkrm/apache> Order allow,deny Allow from all </Directory>
Alias /static /work/vkrm/static
<Directory /work/vkrm/static> Options FollowSymLinks Order deny,allow Allow from all </Directory>

7. Restart Apache

su -c service restart httpd

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.