How to setup Apache 2.4, WSGI and Django

After a small amount of research, here is my solution to setting up Virtual Hosts on Apache 2.4.

  • 18 Nov 2013
  • Matthew Wittering

So in the last week I tried to upgrade my Ubuntu 13.04 droplet on DigitalOcean to Ubuntu 13.10. It hosts a few some small sites using Apache2, Python, Django and mod_wsgi. After updating the Ubuntu instance my Apache2 version was incremented to Apache 2.4. After researching the issue for a little while I found that, Apache 2.4 wants enabled virtual host config files to end in .conf by default.

After I'd modified the configurations to use the .conf file suffix and reloaded the Apache2 service, I discovered another issue to over come. All my pages on my virtual hosts were returning a 403 Forbidden error messages. After a few more queries on DuckDuckGo, I'd learned that it was necessary for my to add the Directory declaration in my .conf files to grand access to all paths.

<Directory />
    Require all granted

Once I'd completed all these modification and restarted the service everything was back in business!

An Example .conf file

<VirtualHost *:80>
    ServerName domain.tld
    ServerAlias *.domain.tld
    WSGIScriptAlias / /home/username/public_html/domain.tld/project/app/
    Alias /static/ /home/username/public_html/domain.tld/project/static/
    <Directory />
        Require all granted
    <Location "/static/">
        Options -Indexes