LinuxCommandLibrary

a2dismod

Disable Apache modules

TLDR

Disable a module

$ sudo a2dismod [module]
copy

Don't show informative messages
$ sudo a2dismod [[-q|--quiet]] [module]
copy

SYNOPSIS

a2dismod [options] module [module ...]

PARAMETERS

module
    The name of the Apache2 module to disable. This is typically the filename without the .load or .conf extension (e.g., deflate, rewrite).

-f, --force
    Do not complain if the specified module does not exist or is already disabled. This suppresses error messages.

-q, --quiet
    Suppress all informative messages, showing only errors if they occur.

DESCRIPTION

The a2dismod command is a utility used on Debian/Ubuntu-based systems to disable a specific Apache2 module. Apache2 uses a modular configuration system where modules are typically enabled or disabled by managing symbolic links. When a module is enabled, a symlink exists from /etc/apache2/mods-available/ to /etc/apache2/mods-enabled/. The a2dismod command automates the process of removing this symbolic link, effectively telling Apache2 to no longer load that module's configuration. This command requires root privileges (sudo). After running a2dismod, the Apache2 web server must be reloaded or restarted for the changes to take effect. It's the counterpart to the a2enmod command.

CAVEATS

Root Privileges: This command requires superuser privileges (e.g., using sudo) to modify system configuration files.

No Automatic Reload: a2dismod only modifies configuration files; it does not automatically reload or restart the Apache2 web server. You must manually reload or restart Apache2 (e.g., sudo systemctl reload apache2 or sudo service apache2 reload) for the changes to take effect.

Dependencies: Disabling a module that other active sites or modules depend on can lead to unexpected errors or site malfunctions. Ensure no critical dependencies are broken.

Configuration vs. Binary: This command disables the configuration for a module; it does not remove or uninstall the module's binary files from your system.

RELOADING APACHE AFTER DISABLING A MODULE

It is crucial to reload or restart the Apache2 web server after using a2dismod for the changes to become active. Common commands include:

sudo systemctl reload apache2
or
sudo service apache2 reload

For a full restart (which might cause a brief downtime):
sudo systemctl restart apache2

FINDING MODULE NAMES

To see available module names, you can list the contents of the /etc/apache2/mods-available/ directory:

ls /etc/apache2/mods-available/

Modules are typically listed as modulename.load and sometimes modulename.conf. When using a2dismod, you only need to provide the modulename part (e.g., ls /etc/apache2/mods-available/rewrite.load would mean using rewrite as the module name).

HISTORY

The a2dismod command, along with its counterparts like a2enmod, a2ensite, and a2dissite, is a part of the Apache2 utility suite provided by Debian and Ubuntu distributions. These utilities were developed to simplify the management of Apache's modular configuration system, abstracting away the manual creation and removal of symbolic links in directories like /etc/apache2/mods-enabled/ and /etc/apache2/sites-enabled/. This approach makes Apache configuration more maintainable and less prone to manual errors, especially for administrators managing multiple modules and virtual hosts.

SEE ALSO

Copied to clipboard