Where should the web server root directory go in linux?
Distros use /var/www
because it is for "transient and temporary files". The files installed there are just for checking if the server is working. After that, you can safely delete the folder.
But /var/www
is not where you are supposed to install your own web source files. There is an argument to be made for using /usr/local/<app>
if the web site files are static, but the most appropriate place is in /srv/<app>
or /srv/www/<app>
. Notably, your OS should never write to /usr/local
or /srv
, so they are both safe places for your own shared files. But /srv
is for "data for services provided by this system", which is exactly what web source code is.
Many SysAdmins use non-standard paths in order to avoid an easy-to-guess path in case of attacks.
If you are building an Internet web server I suggest considering a non-standard path.
by default most of Linux Flavors use
var/www/html