Linux FHS – Where to Put Stuff: /srv vs /var

linux

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).

Best Answer

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.

Related Topic