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 Much Bank Balance is Required for US Student Visa in 2024?
Universities Waiving Off GRE/GMAT for Fall & Spring 2024
Sprinter Tyrone's Unblocked Games
Part time Jobs in El Paso; Texas that pay $15, $25, $30, $40, $50, $60 an hour online
Comcast Xfinity Outage in Kipton, Ohio
Walgreens Alma School And Dynamite
How to Watch Braves vs. Dodgers: TV Channel & Live Stream - September 15
อพาร์ทเมนต์ 2 ห้องนอนในเกาะโคเปนเฮเกน
Aktuelle Fahrzeuge von Autohaus Schlögl GmbH & Co. KG in Traunreut
Bjork & Zhulkie Funeral Home Obituaries
Simon Montefiore artikelen kopen? Alle artikelen online
Guidewheel lands $9M Series A-1 for SaaS that boosts manufacturing and trims carbon emissions | TechCrunch
Diesel Mechanic Jobs Near Me Hiring
Kürtçe Doğum Günü Sözleri
Cambridge Assessor Database
Prosser Dam Fish Count
Wausau Obits Legacy
Ibukunore
V-Pay: Sicherheit, Kosten und Alternativen - BankingGeek
Wausau Marketplace
Trivago Sf
Curry Ford Accident Today
Riherds Ky Scoreboard
Little Rock Skipthegames
Shreveport City Warrants Lookup
Conscious Cloud Dispensary Photos
Wonder Film Wiki
Enduring Word John 15
Joann Fabrics Lexington Sc
Sacramento Craigslist Cars And Trucks - By Owner
Ryujinx Firmware 15
Bfri Forum
How To Make Infinity On Calculator
Royals op zondag - "Een advertentie voor Center Parcs" of wat moeten we denken van de laatste video van prinses Kate?
John F Slater Funeral Home Brentwood
Missouri State Highway Patrol Will Utilize Acadis to Improve Curriculum and Testing Management
Google Chrome-webbrowser
Cygenoth
Sukihana Backshots
Davis Fire Friday live updates: Community meeting set for 7 p.m. with Lombardo
Low Tide In Twilight Manga Chapter 53
Setx Sports
Autum Catholic Store
Lucifer Morningstar Wiki
Craigslist/Nashville
Ups Authorized Shipping Provider Price Photos
Mega Millions Lottery - Winning Numbers & Results
Sam's Club Gas Price Sioux City
View From My Seat Madison Square Garden
Maurices Thanks Crossword Clue
Billings City Landfill Hours
Overstock Comenity Login
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.