Apache HTTP Server course

Apache conf-available Directory on Ubuntu and Debian

Learn how /etc/apache2/conf-available and conf-enabled work on Ubuntu and Debian, including a2enconf, a2disconf, validation, reloads, and troubleshooting.

On Ubuntu and Debian, /etc/apache2/conf-available stores optional Apache configuration snippets. These are separate .conf files containing focused Apache directives.

A snippet can define server-wide settings, local policy, or specialized behavior. Unlike a virtual-host file, it is generally not tied to one domain or site. An application package may install a snippet here so its Apache integration can be enabled when needed.

How conf-available and conf-enabled work

A file being present in /etc/apache2/conf-available does not make its directives active. The file is only available for activation.

Active snippets are represented by symbolic links in /etc/apache2/conf-enabled. A symbolic link is a filesystem reference that points to another file. For example:

/etc/apache2/conf-available/example-policy.conf
/etc/apache2/conf-enabled/example-policy.conf -> ../conf-available/example-policy.conf

The source file remains in conf-available, while the matching link in conf-enabled indicates that the distribution's Apache configuration layout should load it. The main file, /etc/apache2/apache2.conf, includes the enabled configuration directories as part of this layout.

Ubuntu and Debian Apache directory layout

Ubuntu and Debian separate configuration files into available and enabled directories. This makes it possible to activate or deactivate a configuration without deleting its source file.

DirectoryPurposeHow it becomes activeTypical scope
conf-availableStores optional Apache configuration snippets.Enable the snippet so a link is created in conf-enabled.Global, local, or specialized server settings.
conf-enabledContains links to snippets Apache should load.Apache includes the enabled directory through its main configuration layout.Global configuration.
mods-availableStores module load files and module-specific configuration.Use the module-management tools, such as a2enmod.Apache modules.
mods-enabledContains links for enabled module configuration.Module activation creates the appropriate links.Apache modules currently enabled.
sites-availableStores virtual-host configurations.Enable a site so a link is created in sites-enabled.One domain, application, or virtual host.
sites-enabledContains links to active virtual-host configurations.Apache loads the enabled site files.Virtual hosts currently active.

Use conf-available for a server-wide snippet, sites-available for a domain-specific virtual host, and mods-available when the configuration belongs to an Apache module.

For related directory concepts, see conf-enabled, mods-available, mods-enabled, sites-available, and sites-enabled.

Inspect available and enabled snippets

List the source files in conf-available:

ls -l /etc/apache2/conf-available/

List the active links in conf-enabled:

ls -l /etc/apache2/conf-enabled/

Comparing these listings shows whether a source file has a matching symbolic link. A file in the first listing without a link in the second listing is not active.

Enable a configuration snippet

Use a2enconf to enable a Debian or Ubuntu Apache configuration snippet. Normally provide the configuration name without the .conf suffix.

sudo a2enconf example-policy

This command expects a file such as /etc/apache2/conf-available/example-policy.conf and creates the corresponding link in /etc/apache2/conf-enabled.

For example, create or install this optional global policy file:

<IfModule mod_headers.c>
    Header always set X-Content-Type-Options "nosniff"
</IfModule>

Save it as /etc/apache2/conf-available/example-policy.conf, then enable and apply it safely:

sudo a2enconf example-policy
sudo apache2ctl configtest
sudo systemctl reload apache2

The Header directive is supplied by the headers module. The module must be enabled before directives supplied by it can be used. The IfModule wrapper prevents the enclosed directive from being processed when that module is unavailable, but it does not replace the need to understand whether the desired behavior is actually active.

Disable a configuration snippet

Use a2disconf with the same name, again normally without the suffix:

sudo a2disconf example-policy
sudo apache2ctl configtest
sudo systemctl reload apache2

Disabling removes the activation link from /etc/apache2/conf-enabled but retains /etc/apache2/conf-available/example-policy.conf. The file can therefore be enabled again later.

CommandPurposeResultFollow-up action
a2enconf nameEnable a configuration snippet.Creates its link in conf-enabled.Run apache2ctl configtest, then reload Apache.
a2disconf nameDisable a configuration snippet.Removes its enabled link while retaining the source file.Run apache2ctl configtest, then reload Apache.
apache2ctl configtestCheck Apache configuration syntax.Reports Syntax OK or identifies an error.Fix errors before applying the change.
systemctl reload apache2Ask the running service to reread configuration.Applies valid changes without a full stop and start.Check service status and logs if behavior is unexpected.

Safe administration practices

  • Prefer a2enconf and a2disconf instead of manually creating or deleting links.
  • Run sudo apache2ctl configtest before every reload or restart after a configuration change.
  • Review global impact carefully. An enabled snippet can affect every virtual host served by that Apache instance.
  • Keep each global setting in one clearly identified file to reduce duplicate directives and conflicts.
  • Reload only after a successful syntax check. A reload applies configuration while allowing the service to continue serving existing connections as appropriate.

Effective configuration and logs

When a setting behaves unexpectedly, inspect both the source and enabled files, then review the effective Apache configuration and the error log. Search the Apache configuration tree for duplicate or competing directives:

sudo grep -RIn "X-Content-Type-Options" /etc/apache2/

Also check the Apache error log for module errors, invalid paths, permission problems, and runtime configuration warnings. See Apache access and error logs for log locations and usage.

Troubleshooting common problems

A file exists in conf-available but has no effect

Common causes are that the file has not been enabled, no matching link exists in conf-enabled, or Apache has not been reloaded.

  1. Enable it with sudo a2enconf snippet-name.
  2. Confirm the link with ls -l /etc/apache2/conf-enabled/.
  3. Run sudo apache2ctl configtest.
  4. Reload with sudo systemctl reload apache2.

Apache reports an unknown directive

The directive may require a module that is not enabled, or it may use syntax unsupported by the installed Apache version. Run apache2ctl configtest to identify the file and line. Enable the required module with the appropriate module-management command when applicable, or correct or remove unsupported directives.

Apache fails to reload

Possible causes include a syntax error, conflicting global directives, invalid permissions, or a referenced path that does not exist. Run the configuration test first, temporarily disable the suspected snippet with a2disconf, and inspect the Apache error log for details.

A setting appears to be enabled twice

The same directive may occur in multiple enabled snippets, apache2.conf, module configuration, or a virtual-host file. Search /etc/apache2 for duplicates and decide whether the setting belongs in global, module, or virtual-host scope.

Exam-relevant summary

  • /etc/apache2/conf-available contains optional configuration snippet files.
  • /etc/apache2/conf-enabled contains symbolic links to snippets Apache should load.
  • Availability is not activation; a source file must be enabled.
  • a2enconf name enables a snippet, usually without .conf.
  • a2disconf name removes the enabled link but preserves the source file.
  • Use apache2ctl configtest before systemctl reload apache2.
  • Global snippets can affect every virtual host, so choose the configuration directory according to scope.