Recently i installed Nginx and want to change the root directory of that but i don't know what the difference is between /var/www
and /srv/www
and when i should use /var/www
or /srv/www
?
Asked
Active
Viewed 4,968 times
5
Saeed Masoumi
- 153
- 1
- 5
1 Answers
11
The difference is: different file structure. Different servers implement slightly different file structures.
Here is a good link that describes common file structures in Linux: Linux Directory Structure (File System Structure) Explained with Examples
From this:
/var – Variable Files
- var stands for variable files. - Content of the files that are expected to grow can be found under this directory. - This includes — system log files (/var/log); packages and database files (/var/lib); emails (/var/mail); print queues (/var/spool); lock files (/var/lock); temp files needed across reboots (/var/tmp);
/srv – Service Data
- srv stands for service. - Contains server specific services related data. - For example, /srv/cvs contains CVS related data.
Based on that, /srv
would seem more appropriate. However, the Ubuntu flavor of Linux for example does not generally use a /srv
file structure and rather uses the var
directory for www
. So I think the key is being consistent with the OS you use.
-
Actually, Ubuntu users are still encourage to use `/srv` too. `/var/www` is for the default, os-installed "websites" such as Apache's "It Works!" landing page. For _your_ stuff, use `/srv` – MestreLion Nov 23 '21 at 05:46
-
@MestreLion Says who? The default page is placed in a subdirectory and it won't be re-created after deletion. Just because you like to do it that way doesn't make it a policy. – Bachsau Apr 14 '22 at 11:24
-
It's not a policy, but rather a _recommendation_. The default page is shipped in Apache's `deb` package from the repositories, so it _could_ be seen as "OS-installed" stuff, just like things in `/usr`. While `/srv` is a standard location for _local_ files, which distributions and system packages should not touch. Says who? The [Filesystem Hierarchy Standard](https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s17.html), and Debian and Ubuntu respect that. There's even a template for enabling `/srv/www` in the default config file `/etc/apache2/apache2.conf` – MestreLion Apr 22 '22 at 02:03