VMware ESXi and vSphere Cluster Management

Apache conf-enabled Directory: Enabling and Disabling Global Configuration Files

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

On Debian and Ubuntu systems, /etc/apache2/conf-enabled/ represents the set of optional, server-wide Apache configuration snippets that are currently active. Understanding this directory helps you safely enable or disable global Apache behavior without deleting configuration files.

This guide assumes basic Linux filesystem navigation, symbolic links, sudo, and Apache service management.

What Is /etc/apache2/conf-enabled?

A configuration snippet is a focused Apache configuration file that adds or changes one area of server behavior. Examples include CGI settings, security headers, logging adjustments, or MIME behavior.

The /etc/apache2/conf-enabled/ directory is the activation layer for optional global Apache snippets. Files present there are normally symbolic links rather than separate configuration copies. Debian and Ubuntu's Apache layout includes enabled snippets, typically with an include such as conf-enabled/*.conf, when Apache starts or reloads.

Therefore, a file being present in conf-enabled generally means that Apache is intended to load it. The actual result still depends on valid syntax and any modules, paths, users, groups, or other resources referenced by the snippet.

Relationship Between conf-available and conf-enabled

/etc/apache2/conf-available/ stores optional global configuration files that are installed or made available but are not necessarily active. /etc/apache2/conf-enabled/ contains links to the selected files that should be loaded.

  • Available: The source configuration file exists under conf-available.
  • Enabled: A symbolic link to that source exists under conf-enabled.
  • Loaded: Apache's include rules find the enabled link, and the configuration passes validation.

The operational relationship is one-way: creating an enabled link activates a source snippet; removing the link deactivates it without deleting the source file. Enabling or disabling is different from editing the configuration itself. The helper commands change which files are selected, while an editor changes the directives inside a file.

DirectoryPurposeTypical contentsHow configuration is enabled
conf-availableStores optional global snippetsFiles such as serve-cgi-bin.confA matching link is created in conf-enabled
conf-enabledStores active global snippet linksSymbolic links to conf-availableApache's include rules load the selected links
mods-availableStores available module definitions and configuration.load and .conf filesa2enmod creates links in mods-enabled
mods-enabledStores enabled module links and module-specific configurationLinks to files in mods-availableApache loads the enabled module layout
sites-availableStores available virtual-host definitionsVirtual-host configuration filesa2ensite creates links in sites-enabled
sites-enabledStores active virtual-host linksLinks to files in sites-availableApache loads the enabled virtual hosts

Symbolic Links and Apache Activation

A symbolic link is a filesystem reference that points to another file. It is similar to a shortcut: the link has its own directory entry, but the referenced file contains the configuration content.

Distribution-managed Apache uses links to separate installed configuration from active configuration. A package can install a source file into conf-available without automatically activating it. An administrator can then select the desired configuration by creating or removing a link in conf-enabled.

Use a detailed listing to identify links and their targets:

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

A result might resemble this:

lrwxrwxrwx 1 root root 39 ... serve-cgi-bin.conf -> ../conf-available/serve-cgi-bin.conf

The leading l indicates a symbolic link, and the arrow shows its target. You can compare enabled links with available source files:

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

It is technically possible to create or delete links with filesystem commands, but a2enconf and a2disconf are preferred because they express the intended Apache administration operation and reduce layout mistakes.

Using a2enconf

a2enconf enables a named configuration snippet from conf-available. Use the configuration name, generally not its full path:

sudo a2enconf serve-cgi-bin.conf

The command creates the corresponding symbolic link in conf-enabled. It does not by itself make a running Apache process reread the configuration. Validate first, then reload:

sudo apachectl configtest
sudo systemctl reload apache2

Only reload after the test reports a successful result, commonly Syntax OK. A full restart is also possible when operational circumstances require a stop/start cycle, but a graceful reload is the normal way to apply a valid configuration adjustment.

Using a2disconf

a2disconf disables a named configuration snippet:

sudo a2disconf serve-cgi-bin.conf

This removes the symbolic link from conf-enabled while preserving the original file in conf-available. The configuration stops being loaded only after Apache is reloaded or restarted.

sudo apachectl configtest
sudo systemctl reload apache2

Before disabling a snippet, verify that no required application or server feature depends on it. Removing a global snippet can affect handlers, aliases, directory permissions, access controls, logging, or other behavior.

Worked Example: serve-cgi-bin.conf

serve-cgi-bin.conf is an example optional snippet associated with CGI execution settings in common Debian and Ubuntu installations. Disabling it can remove CGI-related aliases, directory settings, or handler configuration supplied by that file. Whether CGI is actually needed depends on the applications hosted by the server.

1. Confirm the source and enabled link

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

Confirm that serve-cgi-bin.conf exists in the available directory and that a matching enabled link currently exists.

2. Disable the snippet

sudo a2disconf serve-cgi-bin.conf

3. Check that the link is absent

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

The source file should remain in conf-available, while its link should no longer appear in conf-enabled.

4. Validate and apply the change

sudo apachectl configtest
sudo systemctl reload apache2

When disabled, CGI-related configuration supplied by this snippet is no longer loaded. CGI may stop working if this file provided the required alias, permissions, or handler setup.

5. Enable the snippet again

sudo a2enconf serve-cgi-bin.conf
ls -l /etc/apache2/conf-enabled/
sudo apachectl configtest
sudo systemctl reload apache2
sudo systemctl status apache2

The symbolic link should return to conf-enabled. After a successful validation and reload, Apache again attempts to load the CGI configuration.

Applying and Validating Changes

apachectl configtest checks Apache configuration syntax and consistency. It does not apply changes to the running service.

A reload asks Apache to reread its configuration while avoiding a full stop/start cycle. Existing connections are generally handled more gracefully than with a restart, making reload the normal choice after a valid configuration change.

A restart stops and starts the Apache service. Use it when required by an operational procedure or when a reload is insufficient for the change. Do not use a restart as a substitute for validation.

TaskHelper commandFilesystem resultFollow-up action
Enable a configuration snippetsudo a2enconf name.confCreates a link in conf-enabledRun apachectl configtest, then reload
Disable a configuration snippetsudo a2disconf name.confRemoves its link; source remains availableRun apachectl configtest, then reload
Validate configurationsudo apachectl configtestNo filesystem changeApply changes only if validation succeeds
Reload Apachesudo systemctl reload apache2No link changeCheck service status if the reload fails
Restart Apachesudo systemctl restart apache2No link changeUse only when a full restart is operationally necessary

Available Versus Enabled State

StateFile in conf-availableLink in conf-enabledExpected Apache behavior
Available but disabledPresentAbsentNot loaded through the normal enabled-directory include
Available and enabledPresentPresent and points to sourceLoaded if syntax and dependencies are valid
Missing source file with stale linkAbsentPresent but target is missingMay cause configuration errors or prevent loading
Manually added file not included by the distribution layoutMay be elsewhereNot presentNot loaded unless an applicable include directive references it

Scope and Boundaries

conf-enabled is intended for general server-wide configuration snippets. It is not the directory for every kind of Apache configuration.

  • mods-enabled: Enabled Apache modules and module-specific configuration. Use module management tools such as a2enmod and a2dismod where appropriate.
  • sites-enabled: Enabled virtual-host configuration links.
  • Main Apache configuration: The main configuration file and its include directives determine which directories and files Apache loads.

These directories are conventions provided by Debian and Ubuntu packaging. A manually placed file is not automatically active merely because it exists somewhere under /etc/apache2. Apache must have an include directive that reaches it.

Determining Whether a Snippet Is Active

  1. Check whether the source file exists:
ls -l /etc/apache2/conf-available/
  1. Check whether a matching link exists in the enabled directory:
ls -l /etc/apache2/conf-enabled/
  1. Inspect the target shown after the -> marker and confirm it points to the expected source.
  2. Run a configuration test and inspect service state after any change:
sudo apachectl configtest
sudo systemctl status apache2

A present link indicates selection for loading; it does not prove that Apache successfully loaded the file. Syntax errors or missing dependencies can prevent a reload.

Safe Administration Practices

  • List conf-available before enabling or disabling a name, and use the exact filename expected by the helper command.
  • Review a configuration file before activation, especially when it changes access controls, handlers, logging, MIME behavior, or security settings.
  • Run sudo apachectl configtest after every configuration change and before reloading.
  • Prefer a2enconf and a2disconf over manually modifying generated symlinks.
  • Avoid editing or deleting enabled links directly except when diagnosing package-layout or filesystem problems.
  • Document local changes so package upgrades and configuration-file changes can be reviewed safely.
  • After disabling a snippet, verify that no required application feature depends on it.

Troubleshooting

a2enconf says the configuration does not exist

The name may be misspelled, the file may be absent from conf-available, or the package that supplies it may not be installed.

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

Use the exact available filename. If it is absent, restore the configuration file or install the package that provides it.

Apache fails to reload after enabling a snippet

Run the validation command to identify the error:

sudo apachectl configtest

Common causes include invalid syntax, a missing module, an unavailable path or user, or a conflict with another enabled configuration. Review the referenced file and its dependencies. If necessary, disable the newly enabled snippet, validate again, and reload only after the errors are corrected.

Disabling a configuration appears to have no effect

First verify that the link was removed and reload Apache. The same directive may also be defined in a virtual host, module configuration, another global snippet, or the main configuration.

ls -l /etc/apache2/conf-enabled/
sudo systemctl reload apache2

Search the Apache configuration tree for duplicate directives and related include statements when the setting remains active.

A link points to a missing file

A package change may have removed or renamed the source file, or the link may have been created incorrectly. Inspect the target with ls -l, restore the source or remove the stale enabled link through the appropriate helper workflow, then run a configuration test before reloading.

CGI stops working after disabling serve-cgi-bin.conf

The snippet may have supplied the CGI alias, directory permissions, or handler setup required by the application. Confirm whether CGI is needed. If it is, re-enable the snippet or review the separate module and virtual-host requirements for CGI.

Inspecting service status and logs

If a reload or restart fails, inspect systemd's service state and recent Apache messages:

sudo systemctl status apache2
sudo journalctl -u apache2 -n 50 --no-pager

Summary

  • /etc/apache2/conf-available contains optional global Apache snippets.
  • /etc/apache2/conf-enabled contains symbolic links for the snippets selected for activation.
  • a2enconf name.conf creates an enabled link, while a2disconf name.conf removes it without deleting the source.
  • Validate with apachectl configtest before applying changes.
  • Use a graceful service reload for normal configuration changes and inspect status and logs when loading fails.
  • Keep global snippets, modules, and virtual hosts conceptually separate by using conf-enabled, mods-enabled, and sites-enabled for their respective roles.

For the focused directory reference, see Apache conf-enabled Directory.