How to enable or disable Apache modules (2024)

Apache is a widely used web server that supports a modular architecture. This allows administrators to add or remove specific functionalities by enabling or disabling modules. Managing these modules effectively is crucial for optimizing the performance and security of your Apache server. The process varies depending on the Linux distribution in use.

How to enable or disable Apache modules (1)

On Debian-based systems like Ubuntu, the a2enmod and a2dismod commands are available for managing modules. These commands simplify the process by automatically adjusting the configuration files. For distributions like RedHat and CentOS, module management requires manually editing the configuration files to add or remove LoadModule directives.

Understanding the differences in these methods ensures that you can effectively manage your Apache server in any environment. Whether through command-line utilities or manual configuration, these techniques allow you to control which modules are active, thereby tailoring the server to your specific needs.

Options Debian, Ubuntu openSUSE and SLES Fedora Core, CentOS, RHEL macOS homebrew xampp
a2enmod support yes yes no no no no
Loadmodule directive n/a LoadModule <module_name>_module <module_location>/mod_<module_name>.so

Steps to enable or disable Apache modules using a2enmod and a2dismod:

The a2enmod command is used to enable an Apache module, while a2dismod is used to disable a module. These commands are specific to Debian-based systems such as Ubuntu. They work by creating or removing symbolic links in the Apache configuration directory. This method is quick and straightforward, making it a preferred choice for many administrators.

To manage Apache modules using these commands, first, ensure that the desired module is installed. Then, use a2enmod to enable the module or a2dismod to disable it. Finally, restart the Apache service to apply the changes.

  1. List available modules.

    $ ls /etc/apache2/mods-available/access_compat.load dir.conf proxy_express.loadactions.conf dir.load proxy_fcgi.loadactions.load dump_io.load proxy_fdpass.loadalias.conf echo.load proxy_ftp.confalias.load env.load proxy_ftp.loadallowmethods.load expires.load proxy_hcheck.loadasis.load ext_filter.load proxy_html.confauth_basic.load file_cache.load proxy_html.loadauth_digest.load filter.load proxy_http2.loadauth_form.load headers.load proxy_http.loadauthn_anon.load heartbeat.load proxy.loadauthn_core.load heartmonitor.load proxy_scgi.loadauthn_dbd.load http2.conf proxy_uwsgi.loadauthn_dbm.load http2.load proxy_wstunnel.load##### snipped

    Related: How to view a list of modules in Apache

  2. List enabled modules.

    $ ls /etc/apache2/mods-enabled/access_compat.load authz_user.load filter.load proxy_http.loadalias.conf autoindex.conf mime.conf proxy.loadalias.load autoindex.load mime.load reqtimeout.confauth_basic.load deflate.conf mpm_event.conf reqtimeout.loadauthn_core.load deflate.load mpm_event.load setenvif.confauthn_file.load dir.conf negotiation.conf setenvif.loadauthz_core.load dir.load negotiation.load status.confauthz_host.load env.load proxy.conf status.load
  3. Enable module using a2enmod utility.

    $ sudo a2enmod rewriteEnabling module rewrite.To activate the new configuration, you need to run: systemctl restart apache2
  4. Disable module using a2enmod utility.

    $ sudo a2dismod statusModule status disabled.To activate the new configuration, you need to run: systemctl restart apache2
  5. Reload or restart the Apache service to apply the changes.

    $ sudo systemctl restart apache2

    Related: How to manage the Apache web server service

  6. Check if modules are loaded.

    $ sudo a2query -m rewrite[sudo] password for user: rewrite (enabled by site administrator)

Steps to enable or disable Apache modules manually:

For systems that do not support a2enmod and a2dismod, module management requires manual editing of the Apache configuration files. This method is universal and works across all Linux distributions. It involves adding or removing LoadModule directives in the appropriate configuration files.

To manually enable or disable a module, open the configuration file where the LoadModule directive is located. Add the directive to enable the module, or comment it out to disable it. After making changes, restart the Apache service to apply them.

  1. Open the terminal.

  2. Install module if not already installed.

    Related: How to install Apache modules

  3. Check for existing LoadModule directives.

    $ sudo grep -nr LoadModule /etc/{httpd,apache2}/etc/httpd/conf/httpd.conf:53:# have to place corresponding `LoadModule' lines at this location so the/etc/httpd/conf/httpd.conf:59:# LoadModule foo_module modules/mod_foo.so/etc/httpd/conf.modules.d/00-base.conf:6:LoadModule access_compat_module modules/mod_access_compat.so/etc/httpd/conf.modules.d/00-base.conf:7:LoadModule actions_module modules/mod_actions.so/etc/httpd/conf.modules.d/00-base.conf:8:LoadModule alias_module modules/mod_alias.so/etc/httpd/conf.modules.d/00-base.conf:9:LoadModule allowmethods_module modules/mod_allowmethods.so/etc/httpd/conf.modules.d/00-base.conf:10:LoadModule auth_basic_module modules/mod_auth_basic.so/etc/httpd/conf.modules.d/00-base.conf:11:LoadModule auth_digest_module modules/mod_auth_digest.so/etc/httpd/conf.modules.d/00-base.conf:12:LoadModule authn_anon_module modules/mod_authn_anon.so/etc/httpd/conf.modules.d/00-base.conf:13:LoadModule authn_core_module modules/mod_authn_core.so/etc/httpd/conf.modules.d/00-base.conf:14:LoadModule authn_dbd_module modules/mod_authn_dbd.so/etc/httpd/conf.modules.d/00-base.conf:15:LoadModule authn_dbm_module modules/mod_authn_dbm.so
  4. Open the Apache configuration file containing the LoadModule directive of the module that you want to enable or disable using your preferred text editor.

    $ sudo vi /etc/httpd/conf.modules.d/00-base.conf
  5. Comment out the LoadModule directive associated with the module to disable a module.

    #LoadModule rewrite_module modules/mod_rewrite.so
  6. Uncomment a commented LoadModule directive to re-enable a module.

    LoadModule rewrite_module modules/mod_rewrite.so
  7. Manually add a LoadModule directive for module that is installed but without a pre-configured LoadModule directive such as in homebrew.

    LoadModule php_module /opt/homebrew/opt/php/lib/httpd/modules/libphp.so "Mohd Shakir Zakaria"

    Related: Location for Apache modules

  8. Save and close the configuration file.

  9. Restart the Apache service to apply the changes.

    $ sudo systemctl restart apache2

    Related: How to manage the Apache web server service

  10. Check if module is loaded or unloaded.

    $ httpd -M | grep rewrite rewrite_module (shared)

    Related: Apache binary name for different distribution
    Related: How to view a list of modules in Apache

How to enable or disable Apache modules (2)

How to enable or disable Apache modules (3)

Author: Mohd Shakir Zakaria
Mohd Shakir Zakaria is an experienced cloud architect with a strong development and open-source advocacy background. He boasts multiple certifications in AWS, Red Hat, VMware, ITIL, and Linux, underscoring his expertise in cloud architecture and system administration.

How to enable or disable Apache modules (4) How to enable or disable Apache modules (5)How to enable or disable Apache modules (6) How to enable or disable Apache modules (7)

Discuss the article:

Comment anonymously. Login not required.

How to enable or disable Apache modules (2024)
Top Articles
How to Improve your Form Conversion Rates - 12 Effective Ways
When can a debt collector report my debt to a credit reporting company? | Consumer Financial Protection Bureau
Cold Air Intake - High-flow, Roto-mold Tube - TOYOTA TACOMA V6-4.0
Jazmen Jafar Linkedin
No Limit Telegram Channel
What spices do Germans cook with?
Craigslist Motorcycles Jacksonville Florida
Sportsman Warehouse Cda
Tap Tap Run Coupon Codes
Crime Scene Photos West Memphis Three
Irving Hac
Missing 2023 Showtimes Near Lucas Cinemas Albertville
A.e.a.o.n.m.s
Power Outage Map Albany Ny
United Dual Complete Providers
Eva Mastromatteo Erie Pa
Ess.compass Associate Login
Masterkyngmash
Gotcha Rva 2022
Regal Amc Near Me
Hannaford Weekly Flyer Manchester Nh
Essence Healthcare Otc 2023 Catalog
Mineral Wells Skyward
Rek Funerals
Random Bibleizer
4 Methods to Fix “Vortex Mods Cannot Be Deployed” Issue - MiniTool Partition Wizard
Ou Football Brainiacs
Publix Near 12401 International Drive
12657 Uline Way Kenosha Wi
Housing Intranet Unt
Eegees Gift Card Balance
Elanco Rebates.com 2022
Does Circle K Sell Elf Bars
Melissa N. Comics
Spy School Secrets - Canada's History
Flixtor Nu Not Working
Petsmart Distribution Center Jobs
Kvoa Tv Schedule
Gold Nugget at the Golden Nugget
Mta Bus Forums
Game8 Silver Wolf
How are you feeling? Vocabulary & expressions to answer this common question!
Levothyroxine Ati Template
Telugu Moviez Wap Org
Fifty Shades Of Gray 123Movies
WorldAccount | Data Protection
The best bagels in NYC, according to a New Yorker
Author's Purpose And Viewpoint In The Dark Game Part 3
511Pa
Bustednewspaper.com Rockbridge County Va
Unpleasant Realities Nyt
Latest Posts
Article information

Author: Rev. Leonie Wyman

Last Updated:

Views: 5589

Rating: 4.9 / 5 (79 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Rev. Leonie Wyman

Birthday: 1993-07-01

Address: Suite 763 6272 Lang Bypass, New Xochitlport, VT 72704-3308

Phone: +22014484519944

Job: Banking Officer

Hobby: Sailing, Gaming, Basketball, Calligraphy, Mycology, Astronomy, Juggling

Introduction: My name is Rev. Leonie Wyman, I am a colorful, tasty, splendid, fair, witty, gorgeous, splendid person who loves writing and wants to share my knowledge and understanding with you.