Skip to main content

Posts

Showing posts from August, 2013

Running django on apache with mod_wsgi in Ubuntu/Linux Mint

Django comes with a built in web server that should only be used in development. Integrating django and apache is a bit messy. Apart from Django and Apache itself, libapache2-mod-wsgi is needed to run django with apache2. There are four steps involved. Creating a wsgi file that enables wsgi handler . Creating a conf file in sites-available directory of apache Enabling the site and reloading apache configuration Adding a host entry that points to localhost for the site Detailed Steps First to create a mysite.wsgi file in any directory of your choice with following code [python] import os import sys sys.path = ['/var/www/mysite'] + sys.path # change the path to project directory os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' import django.core.handlers.wsgi.WSGIHandler() [/python] Then create mysite.conf file in /etc/apache2/sites-available directory and write following code [xml] <VirtualHost *.80> WSGIScriptAlias / /home/user/mys