Beginner Fundamentals
Configuration Files
Apache is configured entirely through plain text files. The layout differs between distributions, so knowing where files live is the first step.
Main Configuration File
- Debian/Ubuntu:
/etc/apache2/apache2.conf - Red Hat/CentOS:
/etc/httpd/conf/httpd.conf
This file is the entry point. It loads other files using Include directives.
Debian Directory Layout
Debian splits configuration into directories with enabled/available pairs:
conf-available/andconf-enabled/for general snippets.mods-available/andmods-enabled/for modules.sites-available/andsites-enabled/for virtual hosts.
The -enabled directories contain symbolic links to files in -available.
Including Other Files
# Load every enabled site configuration
IncludeOptional sites-enabled/*.conf
# Load a single file
Include conf-available/security.conf
Test Before Reloading
Always check syntax before applying changes:
sudo apache2ctl configtest
# or
sudo apachectl -t
A Syntax OK message means it is safe to reload Apache.