1

I've followed the excellent tutorial https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-apache-and-mod_wsgi-on-centos-7 to install Apache, mod_wsgi, and Django. All such tutorials leave the location of the python virtual environment and Django project up to the developer, but I'm wondering if there is any Best Practice for selecting an appropriate location. For example, the tutorial suggests creating a virtual environment in the user's home directory:

mkdir ~/myproject
cd ~/myproject
virtualenv myprojectenv

and

WSGIDaemonProcess myproject python-path=/home/user/myproject:/home/user/myproject/myprojectenv/lib/python2.7/site-packages

(Python 3.4 wisely discarded virtualenv, replacing it with the automatically-created version-specific pyvenv-3.4.)

Now that Apache successfully displays the Django 1.8 startup page ("Get to work!"), I want to put the project in a location more suitable to a production environment than my home directory. Options include:

1) The Apache ServerRoot /etc/httpd - that was my first thought, except that /etc is (should be?) used just for configuration information, not installed software

2) Leave it in my home directory /home/username/myproject - undesirable because I'd rather not give permission for httpd to read my home directory, and because I'd rather not be able to accidentally mess up the project when logged in as me.

3) Create a project directory in /home, e.g. /home/myproject or /home/web/myproject, without creating a user account for myproject or web. That's my current preferred option, but it seems a bit strange to have directories in /home not owned by a user. All files in the project would be owned by root:apache, with read-only permission for the apache daemon and no permissions for world.

4) Elsewhere, such as /bin, /lib, or /lib64, none of which seem particularly suitable.

5) DocumentRoot /var/www - DEFINITELY NOT!

So are there any best practice conventions for where to set up a production Django project on a Linux server?

Dave
  • 3,834
  • 2
  • 29
  • 44

1 Answers1

2

By Filesystem Hierarchy Standard the site specific services running on the server should go under /srv.

In your case this could be /srv/django/myproject.

Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435