Proper project path and directory permissions for Ubuntu/Nginx/Django application deployment?

By : Jeewes


I'm learning to deploy Django application with Nginx on top of Ubuntu. As far as I know /var/www/<project_root> is one common place to place the Django project.


I'm not sure if /var/www is considered to be the good and safe practice for the project or is there some other options that are considered more appropriate. Also I'm not totally sure who should be the owner of the project dir and which permissions should it have.


  1. Where should I place the Django project in Ubuntu filesystem?
  2. Which user should own the project directory?
  3. What permissions should the project directory and files

I know there is no definitive answer for these guestions, but I'm pretty sure there are some common good practices that are widely considered to be safe.

By : Jeewes


Actually, /var/www is a bad place for your Django code. It's the default DocumentRoot for Apache, so is the place were it looks to serve files to users; but Django code is not files that should be served, it's code that should be run. Putting the code there allows the possibility that a misconfiguration permits your code to be served directly to users, which is a big security risk.

Apart from that, it doesn't really matter where the code goes. Personally I like /srv.

This video can help you solving your question :)
By: admin