5

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!

astorije
  • 183
  • 3
  • 9

3 Answers3

5

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

2

According to http://lintian.debian.org/tags/dir-or-file-in-var-www.html

Debian packages should not install files under /var/www. This is not one of the /var directories in the File Hierarchy Standard and is under the control of the local administrator. Packages should not assume that it is the document root for a web server; it is very common for users to change the default document root and packages should not assume that users will keep any particular setting.

So, this simply seems like a warning for package authors to not assume that /var/www is the document root, and not to install files there. Indeed, on my Debian system, it's not even the default root, where the default root is /usr/share/nginx/html (don't recall if I had nginx installed from the Debian collection or directly from nginx.org).

I see nothing that prevents you from placing a production site in /var/www.

cnst
  • 13,848
  • 9
  • 54
  • 76
  • OK so you do recommend to place any production website in `/var/www`, right? Thanks for your answer! (damn, I wanted to be the one getting you over the 1k rep bar... :P) – astorije Mar 21 '13 at 17:18
  • Hop, 1k! :-) I will probably validate your answer, once I'll make sure to understand things properly... – astorije Mar 21 '13 at 18:05
  • lol, you still can, by accepting the answer! :-) Where you put your files would not necessarily matter that much (e.g. if you have only one partition). On the other hand, on my OpenBSD server, I have several partitions, and `/var/www` is a separate partition (shows separately under `df`), so, in that case, it does make a difference. But unless you know what you're doing, you shouldn't worry about this, and with a single partition, any reasonable location should be good -- just don't place it in `/tmp`. :-) – cnst Mar 21 '13 at 18:05
  • nice! it shows as "1,001", not a "1k" yet. I guess it has to be above to show up with a `k`. :) – cnst Mar 21 '13 at 18:07
  • For now, everything is on one partition, but the /var will eventually end up on a second existing (and empty) partition. I am just looking for the proper way to start things... :-) By the way, I also have `/usr/share/nginx/www/` as my default root for now, but I wanted to know if my projects should go there or in a `/var/www`... – astorije Mar 21 '13 at 18:09
1

/srv/www is where I keep my web application files. I leave /var/www for web packages that I install with apt such as wordpress. If I set up wordpress by hand, I will put it in /srv/www.

Having said all of that, I have an issue with debian NOT creating the /var/www directory by default despite setting that directory as the home of the www-data user. Installing nginx does not create the directory either. Installing apache does. It is just arbitrary.

dori
  • 11
  • 1
  • Thanks for your input. However, I decided to use `var/www` as my default document root for my websites, according to suggestions of this thread and other explanations on the Internet. – astorije Apr 19 '13 at 09:46