Convention on directory of file outside /var/www

4

1

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?

CatShoes

Posted 2013-02-01T13:24:53.057

Reputation: 163

Read up about UNIX Filesystem Hierarchy on this site: http://www.pathname.com/fhs/

– BenjiWiebe – 2013-02-01T13:33:36.083

@BenjiWiebe Thank you, updated question. Also, you assumed I hadn't already read that. – CatShoes – 2013-02-01T14:07:32.523

Answers

2

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!

BenjiWiebe

Posted 2013-02-01T13:24:53.057

Reputation: 7 672

Not sure why I hadn't marked as answer long ago. Sorry about that. +1 too – CatShoes – 2013-08-26T21:04:23.263