Apache
web server read its configuration file every time it's started. The configuration file is stored in plain text format and Apache
will need to be restarted every time there are changes in the configuration file for the changes to take effect.
Location of Apache
's main configuration file is set during compile time and differ between distributions. The configuration will be splitted into multiple files for ease of management and separation of concern and will then be called from the main configuration file using Include
and IncludeOptional
directives .
You can always check the location of the main configuration file by running the Apache
binary for your distribution with the -V
option and then look for the SERVER_CONFIG_FILE
value.
$ apachectl -V Server version: Apache/2.4.41 (Unix) Server built: Nov 9 2019 07:53:54 Server's Module Magic Number: 20120211:88 Server loaded: APR 1.5.2, APR-UTIL 1.5.4 Compiled using: APR 1.5.2, APR-UTIL 1.5.4 Architecture: 64-bit Server MPM: prefork threaded: no forked: yes (variable process count) Server compiled with.... -D APR_HAS_SENDFILE -D APR_HAS_MMAP -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) -D APR_USE_FLOCK_SERIALIZE -D APR_USE_PTHREAD_SERIALIZE -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT -D APR_HAS_OTHER_CHILD -D AP_HAVE_RELIABLE_PIPED_LOGS -D DYNAMIC_MODULE_LIMIT=256 -D HTTPD_ROOT="/usr" -D SUEXEC_BIN="/usr/bin/suexec" -D DEFAULT_PIDLOG="/private/var/run/httpd.pid" -D DEFAULT_SCOREBOARD="logs/apache_runtime_status" -D DEFAULT_ERRORLOG="logs/error_log" -D AP_TYPES_CONFIG_FILE="/private/etc/apache2/mime.types" -D SERVER_CONFIG_FILE="/private/etc/apache2/httpd.conf"
Combine the output for both HTTPD_ROOT
and SERVER_CONFIG_FILE
If the output doesn't provide absolute full path of the configuration file.
Location of Apache
main configuration file is different for most distributions and they would split the configuration files for ease of management. The following table lists how the configuration file is managed for different distributions:
Option | Debian, Ubuntu | openSUSE and SLES | Fedora Core, CentOS, RHEL | macOS | homebrew | xampp |
---|---|---|---|---|---|---|
Base directory | /etc/apache2/ | /etc/apache2/ | /etc/httpd/ | /private/etc/apache2/ | /usr/local/etc/httpd/ | {installation directory}/apache/conf/ |
Main configuration | apache2.conf | httpd.conf | conf/httpd.conf | httpd.conf | httpd.conf | httpd.conf |
ServerRoot | apache2.conf | n/a | conf/httpd.conf | httpd.conf | httpd.conf | httpd.conf |
DocumentRoot | sites-enabled/*.conf | default-server.conf | conf/httpd.conf | httpd.conf | httpd.conf | httpd.conf, extra/httpd-ssl.conf |
VirtualHost | sites-enabled/*.conf | vhosts.d/*.conf | conf/httpd.conf | httpd.conf, other/*.conf | httpd.conf | httpd.conf, extra/httpd-ssl.conf |
LoadModule | mods-enabled/*.load | loadmodule.conf | conf.modules.d/*.conf | httpd.conf, extra/*.conf | httpd.conf | httpd.conf, extra/*.conf |
Log | apache2.conf, sites-enabled/*.conf | httpd.conf, vhosts.d/*.conf | conf/httpd.conf | httpd.conf | httpd.conf | httpd.conf |
User / Group | apache2.conf, envvars | uid.conf | conf/httpd.conf | httpd.conf | httpd.conf | httpd.conf |
Path for files and directories are relative to the Base directory
if it doesn't start with a /
; e.g. conf/httpd.conf
for CentOS
's main configuration file translates to /etc/httpd/conf/httpd.conf
.
Apart from using different location for the main configuration file, different distributions also use different options for Apache
which could get a bit confusing.
The table below lists some of the default configuration values for Apache
on different distributions.
Option | Debian, Ubuntu | openSUSE and SLES | Fedora Core, CentOS, RHEL | macOS | homebrew | xampp |
---|---|---|---|---|---|---|
ServerRoot | /etc/apache2/ | n/a | /etc/httpd | /usr/ | /usr/local/opt/httpd/ | {installation directory}/apache/ |
DocumentRoot | /var/www/html/ | /srv/www/ | /var/www/html | /Library/WebServer/Documents/ | /usr/local/var/www/ | {installation directory}/htdocs/ |
Module Location | /usr/lib/apache2/modules/ | /usr/lib64/apache2-prefork/ | modules/ | libexec/apache2/ | lib/httpd/modules/ | modules/ |
Access / Error log | /var/log/apache2 | /var/log/apache2/ | logs/ | /private/var/log/apache2/ | /usr/local/var/log/httpd/ | logs/ |
User | www-data | wwwrun | apache | _www | _www | daemon |
Group | www-data | www | apache | _www | _www | daemon |
Binary name | apache2 | httpd | httpd | httpd | httpd | httpd |
Path for files and directories are relative to the Base directory
if it doesn't start with a /
; e.g. modules/
for CentOS
's module directory translates to /etc/httpd/modules/
.
Absolute paths which start with /
such as Ubuntu
's module location are based from the root directory.
Comment anonymously. Login not required.