Apache Main Configuration Files
On a CentOS server, the package manager used to install the Apache web server (such as rpm, yum, or dnf) will typically default to placing the main Apache configuration file in of one of the following locations on the server:
If you have access to the server via command line, you can confirm the exact location that Apache is loading its configuration file from by running the command
httpd -V (if using an older version of Apache)
Either command displays Apache’s version and build parameters:
[root@host ~]# apachectl -V
Server version: Apache/2.4.39 (cPanel)
Server built: May 30 2019 20:13:52
Server's Module Magic Number: 20120211:84
Server loaded: APR 1.7.0, APR-UTIL 1.6.1
Compiled using: APR 1.7.0, APR-UTIL 1.6.1
Server MPM: event
threaded: yes (fixed thread count)
forked: yes (variable process count)
Server compiled with....
-D APR_HAVE_IPV6 (IPv4-mapped addresses disabled)
The HTTPD_ROOT= line will display the root directory for Apache’s installation, and the SERVER_CONFIG_FILE= line will show you the Apache configuration file’s path relative to the root directory of Apache’s installation.
To illustrate this using the example output above, the HTTPD_ROOT= line shows us the root directory of Apache is the following:
The Apache configuration file’s relative path, listed as SERVER_CONFIG_FILE=”conf/httpd.conf“, is within the Apache installation’s root directory, making the full path to the Apache configuration file:
In addition to the main Apache configuration file discussed above, Apache settings can also be placed in the Apache Include files. The Include files are additional configuration files that Apache will read if instructed to in the main configuration file.
The following are examples of how these Include files are referenced in the main configuration file:
The first line instructs Apache to read additional configurations from a specific file /etc/apache2/conf.d/includes/post_virtualhost_global.conf.
The second line instructs Apache to read additional configurations from any files within the folder /etc/apache2/conf.d/ that have .conf at the end of their filename, as the * is a wildcard character. For example, a file named ‘php.conf’ within the /etc/apache2/conf.d/ would be considered an Include file by Apache, and its configurations would be loaded.
You can get a full list of the configuration files Apache currently has loaded, including the main configuration file and any Include files, by running the following command:
apachectl -t -D DUMP_INCLUDES
Accessing Apache Configurations in Control Panels
If the CentOS server has a control panel for server management installed, such as cPanel/WHM or Plesk, its interface will provide you with a graphical menu for editing this Apache configuration file. For more information on navigating each control panel, you can refer to our guides Getting Started With Plesk and Getting Started With cPanel/WHM.
Our Sales and Support teams are available 24 hours by phone or e-mail to assist.