All posts All posts by this author Paper color Change page color Announcements

Django + Apache Configuration on Ubuntu

Considering you have Django and Apache installed.
Create a new project:

~$ django-admin startproject mysite

Now edit apache configuration file:

~$ sudo vi /etc/apache2/sites-available/default

Add the following to the file just before ""

    WSGIDaemonProcess localhost python-path=/home/user/mysite
    WSGIScriptAlias /mysite /home/user/mysite/mysite/wsgi.py
    <Directory /home/user/mysite>
        <Files wsgi.py>
            Order deny,allow
            Allow from all
        </Files>
    </Directory>

Edit the wsgi.py file:

~$ vi /home/user/mysite/mysite/wsgi.py

Add the following to the file -

import sys 
sys.path.append('/home/user/mysite/')

Install and enable mod_wsgi:

~$ sudo apt-get install libapache2-mod-wsgi
~$ sudo a2enmod wsgi

Restart Apache:

~$ sudo service apache2 restart

On the browser:

http://localhost/mysite

And it works!!!

Software Solutions