67

My web development experience has started with Fedora and RHEL but I'm transitioning to Ubuntu. In Fedora/RHEL, the default seems to be using the /var folder while Ubuntu uses /srv.

Is there any reason to use one over the other and where does the line split? (It confused me so much that until very recently, I thought /srv was /svr for server/service)

My main concern deals with two types of folders

  • default www and ftp directories
  • specific application folders like:
    1. samba shares (possibly grouped under a smb folder)
    2. web applications (should these go in www folder, or do can I do a symlink to its own directory like "___/www/wordpress" -> "/srv/wordpress")

I'm looking for best practice, industry standards, and qualitative reasons for which approach is best (or at least why its favored).

1

1 Answer 1

64

This stems from LSB which says "/var contains variable data files. This includes spool directories and files, administrative and logging data, and transient and temporary files." but says this for /srv: "/srv contains site-specific data which is served by this system."

SuSE was one of the first disto's that I used that kept webroot's in /srv - typically Debian/Ubuntu/RHEL use /var/www - but also be aware that if you install a web application using yum or apt then they will likely end up in /usr/share. Also the packaging guidelines for Fedora say that a "package, once installed and configured by a user, can use /srv as a location for data. The package simply must not do this out of the box".

On balanced reflection I would say keep to /var/www - or you can do both by making /var/www a symlink to /srv/www. I know that on oracle RDBMS systems that I build I often create /u01 /u02 etc as symlinks to /home/oracle. The reason for this is that many DBA's expect to find things in /u01 and many others expect /home/oracle. The same can be said of Sysadmins in general - some will instinctively look in /var/www and some in /srv/www while others like myself will grep the apache config for the DocumentRoot.

Hope this provides some guidance for you.

3
  • 11
    I usually put "served" resources under /srv, mostly for storage and backup reasons. This way served data can be in a storage pool different from system managed files such apt cache and logs, and it's easier to accomodate more space if needed.
    – gerlos
    May 16, 2016 at 22:42
  • 7
    Using the /srv partition is particularly useful when you have separate drives mounted on /var and /srv and do not want your logging to impact your IO. It is worth mentioning that Apache comes with Directory directives for /srv as well, they are just commented out.
    – Tim
    May 28, 2017 at 22:23
  • 3
    Here are some links to the documentation of the Linux Filesystem Hierarchy: For /srv tldp.org/LDP/Linux-Filesystem-Hierarchy/html/srv.html and for /var tldp.org/LDP/Linux-Filesystem-Hierarchy/html/var.html
    – ChristophK
    Jul 26, 2020 at 11:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .