/srv
data this host serves to others/srv is for the data a server hands out. The files of a web site, an FTP area, a shared repository — whatever this machine exists to serve. The standard sets it aside for that purpose, though many distributions leave it empty and use /var/www instead.
The data the machine serves, kept apart from the machine itself.
Why it exists
Every directory at the top of the tree is there for a reason. This is the problem /srv solves.
An administrator arriving at an unfamiliar server can look in one directory to find what it serves, without reading every service’s configuration.
Programs can be reinstalled; the site’s content cannot. With the content in one tree, the backup is one path.
What you find inside
Not everything, but the entries worth recognising. Each is marked as a directory, a file, a link or a device.
- wwwdirectoryWeb site files, where the administrator has chosen /srv for them.
- ftpdirectoryThe files an FTP server offers.
- gitdirectoryRepositories shared from this host.
- nfsdirectoryDirectories exported to other machines over NFS.
At the terminal
Four commands that show what this directory is doing on a real machine.
ls /srvSee whether this machine keeps served data here at all.
sudo mkdir -p /srv/www/exampleCreate a directory for a site’s files.
du -sh /srvShow how much data the host is serving.
grep -r "root" /etc/nginx/sites-enabled/Find where a web server is actually told to serve from.
Handle with care
What goes wrong here, and what someone securing or attacking the machine looks at.
A file under a web root is one request away from the internet. Backups, .git directories and files holding passwords do not belong in it.
The web server should be able to read the site and write only where uploads go. A site writable throughout can be rewritten by whoever breaks in.