By /var/www I am generically referring to the document root for Apache. Often times you want to work with files, but don't want them inside the doc root (PHP examples come to mind). The general advice is "put these files outside the document root and then include them in the appropriate manner".

That's well and good, but are there any conventions on where to put these files outside the doc root. I have often seend (and done) things like /var/some_dir, but is that really the intent of the /var directory? Is there a better location?

I've read the FHS and it seems to imply that /var is not the ideal location for such a directory.

Section 5.1:

/var contains variable data files. This includes spool directories and files, administrative and logging data, and transient and temporary files

Applications must generally not add directories to the top level of /var. Such directories should only be added if they have some system-wide implication, and in consultation with the FHS mailing list

Sure the files that would be going there are variable data files, but certainly of substance markedly different that the description provided in the above quote.

Nevertheless, no other directory seems like a better fit.

/opt - The files are not a third-party software application

/home - The files do not belong to a specific user

/usr - This dir should have read-only data, but does not seem to have an appropriate subdirectory

Certainly, I can't be the first person to raise this question?

  • Read up about UNIX Filesystem Hierarchy on this site: pathname.com/fhs – BenjiWiebe Feb 1 '13 at 13:33
  • @BenjiWiebe Thank you, updated question. Also, you assumed I hadn't already read that. – CatShoes Feb 1 '13 at 14:07

In the Filesystem Hierarchy Standard,

/srv contains site-specific data which is served by this system.

There is your answer. It seems that /srv is the correct place to put this, but if you put it into /var/www, you are in good company.

Hope this helps!

  • Not sure why I hadn't marked as answer long ago. Sorry about that. +1 too – CatShoes Aug 26 '13 at 21:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.