Apache – the purpose of Apache2’s configuration files

apache-httpdconfiguration

Why does Apache2 have multiple configuration files? What are their roles? I found some information about older Apache versions, but it's usually deprecated, and the official Apache documentation doesn't explain the logic of splitting up the configuration files and what they're for.

Best Answer

Hmm. From one point of view, you can dump all the configuration into one httpd.conf file, but this would be... hard to read.

Most distros will divide up the configuration by having httpd.conf include subdirectories. You may want to look at distro-specific documentation, for example:

https://help.ubuntu.com/12.04/serverguide/httpd.html

For Ubuntu, the Apache configuration directory is /etc/apache2. The primary subdirectories for your organizational convenience are conf.d, mods-available, mods-enabled, sites-available and sites-enabled. You would keep your module configuration in the mods-available directory, and your virtualhost configurations in the sites-available directory. Note that the *-enabled directories contain symlinks to the corresponding *-available directories, so you can keep a bunch of things floating around in *-available, but only activate them by symlinking from the *-enabled directory. The master httpd.conf file will do an include of what's in the *-enabled directories.

RHEL/CentOS doesn't work that way, and leave it somewhat more up to your discretion on how to set up the /etc/httpd base directory. You can dump everything into /etc/httpd.conf; you can create a similar directory structure to Ubuntu (and modify httpd.conf to include the *-available directories that you've made), or some combination thereof.

So, you may want to check your distro's documentation first. As you'll see with the Ubuntu one, they provide links to other resources.

Related Question