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:
httpd -V– The Apache Web Server comes with
apachectlcli 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 –
SERVER_CONFIG_FILEis an absolute path like
/private/etc/apache2/httpd.conf, then that’s the location of your main server configuration settings and
/private/etc/apache2is the folder that should contain other configuration files.
SERVER_CONFIG_FILEis a relative path (eg:
apache2.conf) then join that with
HTTPD_ROOTwhich points to the server root (eg:
/etc/apache2). The final path, i.e.,
/etc/apache2/apache2.confis the location of your main server config file.
Step 2 will give you the main server configuration file and the folder in the path with the name
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.