What and Where Is the Server Root In Apache Web Server
httpd‘s server root is a directory location in the filesystem where the server “lives”, i.e., it typically contains the configuration files at the very least. Sometimes you may also find log files and shared modules in the server root directory location. For instance in Debian and Ubuntu, the
ServerRoot is at
/etc/apache2 and that’s where all the configuration for virtual hosts, modules, ports and the main server lives.
It is important to note that all the relative paths passed to configuration directives like
LoadModule are considered relative to the server root directory. The
IncludeOptional directives are used to load/include other configuration files within one where as
LoadModule links/lists a dynamic/shared module that must be loaded by Apache on runtime.
So how is the value for server root set ?
There are a bunch of options. First, it can be set during the startup of the
httpd daemon (the server itself). It just needs to be passed to the
$ httpd -d /etc/apache2 ...
Second, even if the above is done, it can be overridden by making use of the
ServerRoot directive in the main configuration file (followed by a server restart).
# In [httpd|apache2].conf ServerRoot "/home/httpd"
How do we find the current server root directory ?
We can use the
apachectl program in two different ways to give us the answer:
$ apachectl -D DUMP_RUN_CFG ... ServerRoot: "/etc/apache2" ... $ apachectl -V ... -D HTTPD_ROOT="/etc/apache2" ...
In the output of the first command, you need to look for the value of
ServerRoot where as in the second one it’s
In some environments (like CentOS) it may not be possible to use
apachectl as a front end to
httpd. If that’s the case, use the
httpd binary directly instead of
$ httpd -D DUMP_RUN_CFG ... ServerRoot: "/etc/httpd" ... $ httpd -V ... -D HTTPD_ROOT="/etc/httpd" ...
So now we know what the server root is, why is it important and how to find the current value (location or path) of it.