Apache Modules

Posted by Stefan Kecskes on Friday, July 10, 2015

Apache modules

Apache modules are software components that enhance the functionality and capabilities of the Apache HTTP Server. These modules are designed to extend and customize the server’s core features, allowing administrators and developers to add additional functionalities as per their requirements. Apache modules can be classified into two main categories: core modules and third-party modules. Although each module started as 3rd party module until it was accepted into core modules. Each module is designed to perform a specific function or add a specific feature to the Apache server. By selectively enabling and configuring these modules, administrators can tailor the server’s behavior to meet their specific needs, making Apache a highly flexible and customizable web server solution. I am going to show you few of these modules and how to disable them.

Some examples of modules are:

  • mod_ssl: enables secure communication over HTTPS using SSL/TLS protocol
  • mod_proxy: facilitates proxying requests to other servers, enabling Apache to act as a reverse proxy or a forward proxy
  • mod_headers: allows manipulation of HTTP request and response headers
  • mod_access: controls access to the server based on IP addresses, domain names or other criteria
  • mod_php or mod_perl: enable server-side scripting for dynamic content generation in languages like PERL or PHP
  • mod_auth_basic: authentication and authorization
  • mod_cache: helps improve performance by caching frequently accessed content in memory
  • mod_security: provides enhanced security features, including web application firewall (WAF) functionality
  • mod_log: allows detailed logging and monitoring of server activity
  • mod_gzip or mod_deflate: compression of content before transmitting it, reducing bandwidth usage

Enable modules

Example module will be mod_rewrite that provides URL rewriting capabilities, allowing administrators to modify incoming URLs based on predefined rules. Enable rewrite module with

    sudo a2enmod rewrite

Disable modules

Very similar approach:

sudo a2dismod rewrite

Restart Apache

When you change any module on apache webserver, you will see the status of the module and message that you need to restart apache before the configuration change becomes active

    Enabling module rewrite.
    To activate the new configuration, you need to run:
      service apache2 restart

so just simply run

    service apache2 restart

Although, I believe you don’t need to restart the whole server, reloading the Apache configuration with systemctl reload apache2 should be enough. As you can see, by adding modules to your basic Apache server you can extend its functionality and use it in different ways.