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:

  1. apachectl -V or httpd -V – The Apache Web Server comes with apachectl 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.
  2. Look for the following settings – HTTPD_ROOT and SERVER_CONFIG_FILE.
    1. 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.
    2. If SERVER_CONFIG_FILE is a relative path (eg: apache2.conf) then join that with HTTPD_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.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *