Running multiple Django projects on one Apache instance with mod_wsgi

I did not yet find a page with a concise but complete description of how to run multiple Django instances/projects on one server with Apache. This method is similar to the one in the Django docs, but the docs version does not run the Django instance in a daemon process, therefore it does not work out of the box to run multiple sites in parallel.

I found the following points are the most important:

  • Set SESSION_COOKIE_NAME  in the Django settings, so that there is no conflict between the cookies of your sites (especially when running on the same domain)
  • The STATIC_URL  path might also need to be adjusted to point to the correct subdirectory, e.g. /site1/static
  • The Apache site config must specify a different process-group for each Django site, leading to a sites.conf file like this:

There was no problem using the same strategy with a VirtualHost that uses SSL.

This was also posted as a Github gist.

Leave a Reply

Your email address will not be published. Required fields are marked *