How to Install Multiple Django Sites on the Same Server

Rich Jones

by Rich Jones

Sep 5, 2011


The theme music to this blog post is Against Me! - Unprotected Sex With Multiple Partners.

This is going to be a short and technical post about deploying two or more Django applications on the same server, so that 'http://yourdomain.com/' and 'http://yourdomain.com/otherapp' access two different Django projects.

This assumes that you are using Apache and mod_wsgi to deploy your Django applications. The best guide I've found for doing that is here at Punteney.com.

The basic concept is really simple here, you just need to register a different WSGIScriptAlias for each project you're hosting in your sites-available file.

So, your set up might look something like this:

    WSGIScriptAlias /app2 /var/www/app2/app2/django.wsgi
    <Directory /var/www/app2/app2>
        Order allow,deny
        Allow from all
    </Directory>

    WSGIScriptAlias / /var/www/app1/app1/django.wsgi
    <Directory /var/www/app1/app1>
        Order allow,deny
        Allow from all
    </Directory>

This would make http://yourdomain.com/app2 call app2 and http://yourdomain.com/ call app1. It's important that you put the project which has the suffix BEFORE the one which doesn't, or it else it won't work. Then just call sudo service apache2 restart and test it out. Hopes this helps!


Need a Hacker?

gun.io is where top developers find gigs. Bad developers are screened out, so you'll only hire great hackers at gun.io.

Pssst! Hackers, sign up here!


Comments

About gun.io

We match top developers with high-quality freelance and full-time jobs.

UX/UI Designer

Redwood Agile

St. Petersburg

Full Stack Engineer

Exec

San Francisco

Sign up with GitHub and we'll match you with great gigs based on your open-source portfolio!

blog comments powered by Disqus