How to install and configure Django with mod_wsgi on FreeBSD 8.2

I will assume you have followed all steps in the previous blog post and have FreeBSD 8.2 with Apache, Python and mod_wsgi installed and configured properly. We will use the same directory as we used for the hello world python WSGI web app in the previous article. However, we will re-create it with Django so let’s delete if first:

This will create a myapp directory with couple of files inside it, basically a standard Django project.

The only thing remaning is to configure mod_wsgi. First, edit the Apache configuration file:

#ee /usr/local/etc/apache22/httpd.conf

It should look exactly like the one in my previous blog post, the only thing changed is that I have moved the virtual host into a separate file. So delete the virtual host configuration and add an Include directive:

Include /usr/local/www/myapp/httpd.conf

I am basically telling the Apache to include contents of another httpd.conf file which will be inside the /usr/local/www/myapp folder. This way the virtual host configuration for our app will be inside the app home folder which makes way more sense. So create a new httpd.conf file:

Thanks Richard, another very useful page which saved me a lot of time!

Where you talk about the Apache httpd.conf file and say “delete the virtual host configuration and add an Include directive” – in the previous page where this is configured you have already put the Include directive into this file.

Also the very last thing to do is restart Apache:
# /usr/local/etc/rc.d/apache22 restart

You will get a warning (to be expected as we have not created it yet):
Warning: DocumentRoot [/usr/local/www/myapp/public] does not exist
But of course the Python WSGI app works and we get the Django welcome page.