How to enable and disable modules in apache
In this manual, you will learn how to enable and disable modules in your Apache HTTP Server easily from the command line. Properly managing modules is key to optimizing the performance and security of your web server.
Prerequisites
Before starting, make sure to:
- Have terminal access to your server.
- Have administrator privileges (
rootorsudo). - Have Apache correctly installed.
🚀 If you don't have a Linux server yet, you can easily deploy one with SW Hosting in a matter of seconds.
1. Activating modules in Debian/Ubuntu
In Debian-based distributions, activating a module is very simple using the a2enmod command:
a2enmod modulename
Example
a2enmod rewrite
This command enables the indicated module and prepares it for use in Apache.
2. Deactivating modules in Debian/Ubuntu
To deactivate a module, use the a2dismod command:
a2dismod modulename
Example
a2dismod rewrite
This will disable the selected module.
3. Activating and deactivating modules in Red Hat / CentOS / Fedora
In Red Hat-based systems, module management is performed by directly editing the Apache configuration.
Open the main configuration file:
nano /etc/httpd/conf/httpd.conf
What should you do inside the file?
Look for lines that start with:
LoadModule
Each line represents a module.
- To deactivate a module: add
#to the beginning of the line. - To activate a module: ensure that the line does not have
#at the beginning.
Save changes
- Save:
Ctrl + O - Exit:
Ctrl + X
4. Restart Apache to apply the changes
After activating or deactivating modules, it is necessary to restart the service for the changes to take effect.
In Debian/Ubuntu:
service apache2 restart
In Red Hat / CentOS:
service httpd restart
💡 Alternatively, in modern systems you can use:
systemctl restart apache2 systemctl restart httpd
Final recommendations
- Activate only the modules you actually need.
- Always check the configuration after making changes.
- Consider making a backup copy of the configuration file before modifying it.