Nginx – Where to put project files with nginx

debiandebian-wheezynginx

Looking at the /usr/share/doc/nginx/README.Debian file, we can see this warning:

README for Debian
-----------------

  Files under /var/www/ are not supported as per Debian Policy.
  Please see: http://lintian.debian.org/tags/dir-or-file-in-var-www.html and,
  http://www.pathname.com/fhs/pub/fhs-2.3.html#THEVARHIERARCHY for more
  details and explanations.

After some unsuccessful research (I probably look at the wrong places…), I wonder if:

  1. This warning is a general advice ("don't put your files in /var/www") or if it just means that a standard Debian package installation should not install files under /var/www.
  2. If we are actually discouraged to place the production websites in /var/www, where should I put them?

Thanks by advance!

Best Answer

Reading again the whole thing, IMHO it's nonsense to put your docroot(s) under /usr. It's your data, not nginx's. So, somewhere in /var is the right place obviously. Think about backups. your data is in /var, and websites are part of it. /usr is not, /usr contains packages data (software system data).

Now, my attempt on "why this Debian policy"

It's risky to expose a generic path by default on a webserver. By putting the default setting to /usr/share/nginx/something, Debian ensures that the webserver will not start serving files it should not.

Example

You already have an apache with a docroot in /var/www and you install nginx for something else than apache job (ex serving some static files for speed). So you use a "bare" nginx without PHP nor htaccess support : you don't want to see nginx starting to serve files handled by apache : PHP source files and files that should be protected by htaccesses.

So to my understanting, the Debian policy is not "it's bad practice to have the docroot in /var/www (or rather /var/www/), but more "it's bad pratice for an httpd package to start serving /var/www by default".

This message/behavior is just a (safe) packaging policy. Not a sysadmin good practice