Find installed and enabled apache module in Debian/Ubuntu

In this tutorial we will learn,how to find installed and enabled apache module in Debian/Ubuntu.
The method is applicable to Debian based operating system.As a system admin, sometimes we have to find which Apache module is installed.
Every System Admin has their own style of work. How generally we do ,I am sharing in this post.

What is Apache Module ?

The apache module are software packages made for Apache Web Server. To add some functionality in apache Web Server,we install and enable apache module.
There are lots of Apache Module is available.You can find available apache module list in Apache’s website.

Scenario : We have an apache web server and we want to check the modules. So we have to confirm,the module is installed as well as enabled.

Stepwise Method to find installed and enabled apache module in Debian/Ubuntu

(1) Install Apache module

NOTE: When we first install Apache web server.It shipped with pre-built apache module.In this section,we are describing about installation for those module.Which we have to install later.For eg. mod_proxy module.

First of all install the apache module. Installing the module is pretty much easy.Generally we prefer to install the apache module with Apt-get command if possible.If you are a new bie in linux,we recommend you to use the apt-get command.

Syntax

sudo apt-get install [apache-module-package-name]

For eg. Here in this example, we will install proxy module

sudo apt-get install libapache2-mod-proxy-html

(2) Confirm apache module is installed

To confirm the apache module installed.Best practice is to use the dpkg command.

Syntax


sudo dpkg -l|grep [package-name]

For eg. Lets take example from mod_proxy module,which we have mentioned in this post. The ii status confirmed the installed status of the package.

linux@tuxworld:~$ sudo dpkg -l |grep libapache2-mod-proxy-html
[sudo] password for linux: 
ii  libapache2-mod-proxy-html                     3.0.1-1.1                                 i386         Apache2 filter module for HTML links rewriting
linux@tuxworld:~$ 

(3) Where are the module file reside in Debian/Ubuntu system

You can find the installed Apache module in directory /etc/apache2/mods-available/ . The directory contains the Apache’s module related file.

Below is the example :

linux@tuxworld:~$ sudo ls -la /etc/apache2/mods-available/
[sudo] password for linux: 
total 400
drwxr-xr-x 2 root root 12288 Feb 21 14:13 .
drwxr-xr-x 8 root root  4096 Jan  4 19:27 ..
-rw-r--r-- 1 root root   332 Feb  7  2012 actions.conf
-rw-r--r-- 1 root root    66 Feb  7  2012 actions.load
-rw-r--r-- 1 root root   811 Feb  7  2012 alias.conf
-rw-r--r-- 1 root root    62 Feb  7  2012 alias.load
-rw-r--r-- 1 root root    60 Feb  7  2012 asis.load
-rw-r--r-- 1 root root    72 Feb  7  2012 auth_basic.load
-rw-r--r-- 1 root root    74 Feb  7  2012 auth_digest.load
-rw-r--r-- 1 root root    74 Feb  7  2012 authn_alias.load
-rw-r--r-- 1 root root    72 Feb  7  2012 authn_anon.load
-rw-r--r-- 1 root root    85 Feb  7  2012 authn_dbd.load
-rw-r--r-- 1 root root    70 Feb  7  2012 authn_dbm.load
-rw-r--r-- 1 root root    78 Feb  7  2012 authn_default.load
-rw-r--r-- 1 root root    72 Feb  7  2012 authn_file.load
-rw-r--r-- 1 root root    90 Feb  7  2012 authnz_ldap.load
-rw-r--r-- 1 root root    70 Feb  7  2012 authz_dbm.load
-rw-r--r-- 1 root root    78 Feb  7  2012 authz_default.load
-rw-r--r-- 1 root root    82 Feb  7  2012 authz_groupfile.load
-rw-r--r-- 1 root root    72 Feb  7  2012 authz_host.load
-rw-r--r-- 1 root root    74 Feb  7  2012 authz_owner.load
-rw-r--r-- 1 root root    72 Feb  7  2012 authz_user.load
-rw-r--r-- 1 root root  3265 Feb  7  2012 autoindex.conf
-rw-r--r-- 1 root root    70 Feb  7  2012 autoindex.load
-rw-r--r-- 1 root root    62 Feb  7  2012 cache.load
-rw-r--r-- 1 root root    70 Feb  7  2012 cern_meta.load
-rw-r--r-- 1 root root    69 Feb  7  2012 cgid.conf
-rw-r--r-- 1 root root    60 Feb  7  2012 cgid.load
-rw-r--r-- 1 root root    58 Feb  7  2012 cgi.load
-rw-r--r-- 1 root root    76 Feb  7  2012 charset_lite.load
-rw-r--r-- 1 root root    37 Feb  7  2012 dav_fs.conf
-rw-r--r-- 1 root root    79 Feb  7  2012 dav_fs.load
-rw-r--r-- 1 root root    58 Feb  7  2012 dav.load
-rw-r--r-- 1 root root    68 Feb  7  2012 dav_lock.load
-rw-r--r-- 1 root root    58 Feb  7  2012 dbd.load
-rw-r--r-- 1 root root   438 Feb  7  2012 deflate.conf
-rw-r--r-- 1 root root    66 Feb  7  2012 deflate.load
-rw-r--r-- 1 root root   122 Feb  7  2012 dir.conf
-rw-r--r-- 1 root root    58 Feb  7  2012 dir.load
-rw-r--r-- 1 root root   604 Feb  7  2012 disk_cache.conf
-rw-r--r-- 1 root root    89 Feb  7  2012 disk_cache.load
-rw-r--r-- 1 root root    64 Feb  7  2012 dump_io.load
-rw-r--r-- 1 root root    58 Feb  7  2012 env.load
-rw-r--r-- 1 root root    66 Feb  7  2012 expires.load
-rw-r--r-- 1 root root    72 Feb  7  2012 ext_filter.load
-rw-r--r-- 1 root root    89 Feb  7  2012 file_cache.load
-rw-r--r-- 1 root root    64 Feb  7  2012 filter.load
-rw-r--r-- 1 root root    66 Feb  7  2012 headers.load
-rw-r--r-- 1 root root    62 Feb  7  2012 ident.load
-rw-r--r-- 1 root root    68 Feb  7  2012 imagemap.load
-rw-r--r-- 1 root root    66 Feb  7  2012 include.load
-rw-r--r-- 1 root root   408 Feb  7  2012 info.conf
-rw-r--r-- 1 root root    60 Feb  7  2012 info.load
-rw-r--r-- 1 root root   176 Feb  7  2012 ldap.conf
-rw-r--r-- 1 root root    60 Feb  7  2012 ldap.load
-rw-r--r-- 1 root root    76 Feb  7  2012 log_forensic.load
-rw-r--r-- 1 root root   185 Feb  7  2012 mem_cache.conf
-rw-r--r-- 1 root root    87 Feb  7  2012 mem_cache.load
-rw-r--r-- 1 root root  7439 Jul 16  2012 mime.conf
-rw-r--r-- 1 root root    60 Feb  7  2012 mime.load
-rw-r--r-- 1 root root    81 Feb  7  2012 mime_magic.conf
-rw-r--r-- 1 root root    72 Feb  7  2012 mime_magic.load
-rw-r--r-- 1 root root   666 Feb  7  2012 negotiation.conf
-rw-r--r-- 1 root root    74 Feb  7  2012 negotiation.load
-rw-r--r-- 1 root root  1344 Aug 23  2012 php5_cgi.conf
-rw-r--r-- 1 root root    75 Aug 23  2012 php5_cgi.load
-rw-r--r-- 1 root root  1036 Nov 15  2012 php5.conf
-rw-r--r-- 1 root root    59 Nov 15  2012 php5.load
-rw-r--r-- 1 root root    87 Feb  7  2012 proxy_ajp.load
-rw-r--r-- 1 root root   355 Feb  7  2012 proxy_balancer.conf
-rw-r--r-- 1 root root    97 Feb  7  2012 proxy_balancer.load
-rw-r--r-- 1 root root   803 Feb  7  2012 proxy.conf
-rw-r--r-- 1 root root    95 Feb  7  2012 proxy_connect.load
-rw-r--r-- 1 root root   141 Feb  7  2012 proxy_ftp.conf
-rw-r--r-- 1 root root    87 Feb  7  2012 proxy_ftp.load
-rw-r--r-- 1 root root  2202 Jul 31  2007 proxy_html.conf
-rw-r--r-- 1 root root    94 Jun  8  2012 proxy_html.load
-rw-r--r-- 1 root root    89 Feb  7  2012 proxy_http.load
-rw-r--r-- 1 root root    62 Feb  7  2012 proxy.load
-rw-r--r-- 1 root root    89 Feb  7  2012 proxy_scgi.load
-rw-r--r-- 1 root root  1126 Feb  7  2012 reqtimeout.conf
-rw-r--r-- 1 root root    72 Feb  7  2012 reqtimeout.load
-rw-r--r-- 1 root root    66 Feb  7  2012 rewrite.load
-rw-r--r-- 1 root root  1211 Feb  7  2012 setenvif.conf
-rw-r--r-- 1 root root    68 Feb  7  2012 setenvif.load
-rw-r--r-- 1 root root    66 Feb  7  2012 speling.load
-rw-r--r-- 1 root root  3147 Jul 16  2012 ssl.conf
-rw-r--r-- 1 root root    58 Feb  7  2012 ssl.load
-rw-r--r-- 1 root root   753 Feb  7  2012 status.conf
-rw-r--r-- 1 root root    64 Feb  7  2012 status.load
-rw-r--r-- 1 root root    72 Feb  7  2012 substitute.load
-rw-r--r-- 1 root root    64 Feb  7  2012 suexec.load
-rw-r--r-- 1 root root    70 Feb  7  2012 unique_id.load
-rw-r--r-- 1 root root   604 Feb  7  2012 userdir.conf
-rw-r--r-- 1 root root    66 Feb  7  2012 userdir.load
-rw-r--r-- 1 root root    70 Feb  7  2012 usertrack.load
-rw-r--r-- 1 root root    74 Feb  7  2012 vhost_alias.load
linux@tuxworld:~$ 

Now to find which files are associated with which Apache’s module.Run the below given command

Syntax:

sudo grep  Apache-Module-package-name /etc/apache2/mods-available/

For example. We have installed mod_proxy module (as we are doing in this post)
We will search which files are associated with Apache Module called mod_proxy

Change to directory /etc/apache2/mods-enabled/ . Here in this example,we have used -w option with grep command.The grep with -w option means search particular keyword.You can remove -w option as per your requirement

linux@tuxworld:~$ cd /etc/apache2/mods-enabled/
linux@tuxworld:/etc/apache2/mods-enabled$ sudo grep  -w "mod_proxy" *
proxy.conf:
proxy.load:LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
status.conf:
linux@tuxworld:/etc/apache2/mods-enabled$

Hence,from above example,we found proxy.conf,proxy.load and status.conf are related to mod_proxy module

(3) How to enable Apache module

To enable apache module.You can use a2enmod command.And after enabling apache2 service should be restarted to load the module

Syntax

a2enmod [apache-module-name]

Example.

a2enmod proxy proxy_http

Note: Some Apache modules are shipped while apache web server installation.Not all modules are enabled by-default. We can use same a2enmod command to enable Apache module
Example: a2enmod headers

Alternatively, to enable the Apache Module.We can create symlink of module in /etc/apache2/mods-enabled/

Syntax :

sudo ln -s /etc/apache2/mods-available/Module-File-Name.load /etc/apache2/mods-enabled/Module-File-Name.load

sudo ln -s /etc/apache2/mods-available/Module-File-Name.conf /etc/apache2/mods-enabled/Module-File-Name.conf

After creating symlink, restart the apache service by sudo /etc/init.d/apache2 restart

Lets check in /etc/apache2/mods-enabled/ directory and symlinks pointing to Apache module

Reference example:

linux@tuxworld:~$ sudo ls -la /etc/apache2/mods-enabled/
[sudo] password for linux: 
total 8
drwxr-xr-x 2 root root 4096 Feb 21 14:13 .
drwxr-xr-x 8 root root 4096 Jan  4 19:27 ..
lrwxrwxrwx 1 root root   30 Nov 20  2012 actions.conf -> ../mods-available/actions.conf
lrwxrwxrwx 1 root root   30 Nov 20  2012 actions.load -> ../mods-available/actions.load
lrwxrwxrwx 1 root root   28 Jul 12  2012 alias.conf -> ../mods-available/alias.conf
lrwxrwxrwx 1 root root   28 Jul 12  2012 alias.load -> ../mods-available/alias.load
lrwxrwxrwx 1 root root   33 Jul 12  2012 auth_basic.load -> ../mods-available/auth_basic.load
lrwxrwxrwx 1 root root   33 Jul 12  2012 authn_file.load -> ../mods-available/authn_file.load
lrwxrwxrwx 1 root root   36 Jul 12  2012 authz_default.load -> ../mods-available/authz_default.load
lrwxrwxrwx 1 root root   38 Jul 12  2012 authz_groupfile.load -> ../mods-available/authz_groupfile.load
lrwxrwxrwx 1 root root   33 Jul 12  2012 authz_host.load -> ../mods-available/authz_host.load
lrwxrwxrwx 1 root root   33 Jul 12  2012 authz_user.load -> ../mods-available/authz_user.load
lrwxrwxrwx 1 root root   32 Jul 12  2012 autoindex.conf -> ../mods-available/autoindex.conf
lrwxrwxrwx 1 root root   32 Jul 12  2012 autoindex.load -> ../mods-available/autoindex.load
lrwxrwxrwx 1 root root   26 Mar 12  2013 cgi.load -> ../mods-available/cgi.load
lrwxrwxrwx 1 root root   30 Jul 12  2012 deflate.conf -> ../mods-available/deflate.conf
lrwxrwxrwx 1 root root   30 Jul 12  2012 deflate.load -> ../mods-available/deflate.load
lrwxrwxrwx 1 root root   26 Jul 12  2012 dir.conf -> ../mods-available/dir.conf
lrwxrwxrwx 1 root root   26 Jul 12  2012 dir.load -> ../mods-available/dir.load
lrwxrwxrwx 1 root root   26 Jul 12  2012 env.load -> ../mods-available/env.load
lrwxrwxrwx 1 root root   27 Jul 12  2012 mime.conf -> ../mods-available/mime.conf
lrwxrwxrwx 1 root root   27 Jul 12  2012 mime.load -> ../mods-available/mime.load
lrwxrwxrwx 1 root root   34 Jul 12  2012 negotiation.conf -> ../mods-available/negotiation.conf
lrwxrwxrwx 1 root root   34 Jul 12  2012 negotiation.load -> ../mods-available/negotiation.load
lrwxrwxrwx 1 root root   31 Nov 20  2012 php5_cgi.conf -> ../mods-available/php5_cgi.conf
lrwxrwxrwx 1 root root   31 Nov 20  2012 php5_cgi.load -> ../mods-available/php5_cgi.load
lrwxrwxrwx 1 root root   27 Mar 12  2013 php5.conf -> ../mods-available/php5.conf
lrwxrwxrwx 1 root root   27 Mar 12  2013 php5.load -> ../mods-available/php5.load
lrwxrwxrwx 1 root root   28 Dec 17 21:01 proxy.conf -> ../mods-available/proxy.conf
lrwxrwxrwx 1 root root   33 Feb 21 14:13 proxy_html.conf -> ../mods-available/proxy_html.conf
lrwxrwxrwx 1 root root   33 Feb 21 14:13 proxy_html.load -> ../mods-available/proxy_html.load
lrwxrwxrwx 1 root root   33 Dec 17 21:01 proxy_http.load -> ../mods-available/proxy_http.load
lrwxrwxrwx 1 root root   28 Dec 17 21:01 proxy.load -> ../mods-available/proxy.load
lrwxrwxrwx 1 root root   33 Jul 12  2012 reqtimeout.conf -> ../mods-available/reqtimeout.conf
lrwxrwxrwx 1 root root   33 Jul 12  2012 reqtimeout.load -> ../mods-available/reqtimeout.load
lrwxrwxrwx 1 root root   30 Mar 12  2013 rewrite.load -> ../mods-available/rewrite.load
lrwxrwxrwx 1 root root   31 Jul 12  2012 setenvif.conf -> ../mods-available/setenvif.conf
lrwxrwxrwx 1 root root   31 Jul 12  2012 setenvif.load -> ../mods-available/setenvif.load
lrwxrwxrwx 1 root root   29 Jul 12  2012 status.conf -> ../mods-available/status.conf
lrwxrwxrwx 1 root root   29 Jul 12  2012 status.load -> ../mods-available/status.load
lrwxrwxrwx 1 root root   34 Dec 18 00:44 vhost_alias.load -> ../mods-available/vhost_alias.load
linux@tuxworld:~$ 

In above example, you can see,symlinks are mainly pointing to two file extension i.e .conf and .load .

Tip: .conf file has the module configuration.If the same configuration we write in apache2.conf and in VirtualHost configuration.Then creating symlink to .conf file in mods-enabled directory is not required. Example, rewrite Module


(4) How to find which apache module is installed and enabled

In all above cases,we tried to describe about installation and enabling Apache Module.Now in case,you got the system and want to check quickly the installed and enabled apache module with single command.Here is the answer

sudo apachectl -M

This command give output of those modules,which are installed as well as configured in Apache configuration file .


Posted

in

,

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.