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.confThe 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.
| Directory | Purpose | How it becomes active | Typical scope |
|---|---|---|---|
conf-available | Stores optional Apache configuration snippets. | Enable the snippet so a link is created in conf-enabled. | Global, local, or specialized server settings. |
conf-enabled | Contains links to snippets Apache should load. | Apache includes the enabled directory through its main configuration layout. | Global configuration. |
mods-available | Stores module load files and module-specific configuration. | Use the module-management tools, such as a2enmod. | Apache modules. |
mods-enabled | Contains links for enabled module configuration. | Module activation creates the appropriate links. | Apache modules currently enabled. |
sites-available | Stores virtual-host configurations. | Enable a site so a link is created in sites-enabled. | One domain, application, or virtual host. |
sites-enabled | Contains 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-policyThis 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 apache2The 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 apache2Disabling 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.
| Command | Purpose | Result | Follow-up action |
|---|---|---|---|
a2enconf name | Enable a configuration snippet. | Creates its link in conf-enabled. | Run apache2ctl configtest, then reload Apache. |
a2disconf name | Disable a configuration snippet. | Removes its enabled link while retaining the source file. | Run apache2ctl configtest, then reload Apache. |
apache2ctl configtest | Check Apache configuration syntax. | Reports Syntax OK or identifies an error. | Fix errors before applying the change. |
systemctl reload apache2 | Ask 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
a2enconfanda2disconfinstead of manually creating or deleting links. - Run
sudo apache2ctl configtestbefore 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.
- Enable it with
sudo a2enconf snippet-name. - Confirm the link with
ls -l /etc/apache2/conf-enabled/. - Run
sudo apache2ctl configtest. - 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-availablecontains optional configuration snippet files./etc/apache2/conf-enabledcontains symbolic links to snippets Apache should load.- Availability is not activation; a source file must be enabled.
a2enconf nameenables a snippet, usually without.conf.a2disconf nameremoves the enabled link but preserves the source file.- Use
apache2ctl configtestbeforesystemctl reload apache2. - Global snippets can affect every virtual host, so choose the configuration directory according to scope.