Apache Web Server (HTTPD) Find Location Path to Main Server Configuration
We can quickly find the location or path to the main server configuration folders and files of Apache Web Server (HTTPD) with the following steps:
apachectl -V
orhttpd -V
– The Apache Web Server comes withapachectl
cli tool which can act as a front end to the server binary (httpd
). Executing one of these commands in your terminal will dump the compile time settings of the server.- Look for the following settings –
HTTPD_ROOT
andSERVER_CONFIG_FILE
.- If
SERVER_CONFIG_FILE
is an absolute path like/private/etc/apache2/httpd.conf
, then that’s the location of your main server configuration settings and/private/etc/apache2
is the folder that should contain other configuration files. - If
SERVER_CONFIG_FILE
is a relative path (eg:apache2.conf
) then join that withHTTPD_ROOT
which points to the server root (eg:/etc/apache2
). The final path, i.e.,/etc/apache2/apache2.conf
is the location of your main server config file.
- If
Step 2 will give you the main server configuration file and the folder in the path with the name apache2
or httpd
will be the place that’ll contain all other configuration files as well. It is different from the server root which can be a different path specified by the HTTPD_ROOT
value (as we’ll see below).
Here’s a sample dump from one of my servers:
$ apachectl -V
Server version: Apache/2.4.29
[[other stuff]]
Server compiled with....
[[other redacted settings]]
-D HTTPD_ROOT="/etc/apache2"
-D SERVER_CONFIG_FILE="apache2.conf"
Here’s another dump from my macOS machine where you’ll notice the server root is a different path from the main configuration folder:
$ apachectl -V
Server version: Apache/2.4.51 (Unix)
-D HTTPD_ROOT="/usr"
-D SERVER_CONFIG_FILE="/private/etc/apache2/httpd.conf"
Here’s an article that talks more about apachectl
and shows entire dumps of the command across multiple systems.