It's actually not the "traditional" location at all. Traditionally, anything you installed after the OS went into /usr/local
, and indeed that's the "Classical Apache path layout" (their words) to this day. For a long time, it was /home/httpd
.
What you're seeing is that an Apache that has been configured for a particular OS -- whether that's Red Hat Linux, Mac OS X, GNU, etc - will customize the location. Apache's source are well designed for this, in fact if you trace the value for the ServerRoot in the source files, you'll see that it starts out in this file, config.layout
:
Some excerpts from that file will show you that there's a lot of variety in the docroot location.
IIRC, /var/www
came into my life with the 2000-2001 releases of Red Hat Linux 7.x (not Red Hat Enterprise Linux). For all the reasons you cite above, I thought it didn't make great sense - but the reality is that in the modern era so many other tools and technologies are involved the location moves anyway.
# Classical Apache path layout.
<Layout Apache>
prefix: /usr/local/apache2
datadir: ${prefix}
# GNU standards conforming path layout.
# See FSF's GNU project `make-stds' document for details.
<Layout GNU>
exec_prefix: ${prefix}
datadir: ${prefix}/share+
# Mac OS X Server (Rhapsody)
<Layout Mac OS X Server>
prefix: /Local/Library/WebServer
datadir: ${prefix}
# Darwin/Mac OS Layout
<Layout Darwin>
prefix: /usr
datadir: /Library/WebServer
# Red Hat Linux 7.x layout
<Layout RedHat>
prefix: /usr
datadir: /var/www
# SuSE 6.x layout
<Layout SuSE>
prefix: /usr
datadir: /usr/local/httpd
# BSD/OS layout
<Layout BSDI>
prefix: /var/www
datadir: ${prefix}
# Solaris 8 Layout
<Layout Solaris>
prefix: /usr/apache
datadir: /var/apache
/var/lib/www
would have been more suitable.../srv
/var
is for non-executable non-configuration non-owned-by-a-real-user data that can be edited or change (e.g. should live on a rewritable volume)./var/lib
is specifically for that type of data that should survive a reboot and not be deleted by a maintenance process,isc-dhcp-server
uses/var/lib
to store its record of DHCP leases for example. So it would be a logical spot for web server files.