Authors Top

If you have a few years of experience in the Linux ecosystem, and you’re interested in sharing that experience with the community, have a look at our Contribution Guidelines.

1. Overview

Apache is a popular, secure, open-source HTTP web server used in Linux systems to serve web pages. As an administrator, it’s essential to know how to manage and configure the Apache web server as this allows us to see which modules are currently affecting the server’s performance and security, and to make changes as needed.

In this tutorial, we’ll discuss how to view Apache-enabled modules in Linux using the command line. We’ll focus on the apache2ctl and httpd commands to do this. In addition, we’ll discuss some of the options these commands come equipped with that are important in achieving our goal.

2. Using the apache2ctl Command

apache2ctl command is a command-line utility used to control the Apache HTTP server interface. We can use it to start, stop and restart the Apache web server. We mainly use this command in Ubuntu and Debian-based systems.

First, let’s start the Apache server:

$ apache2ctl start

Once the server starts, we’ll run the apache2ctl -M command to view all enabled modules. For this, we use the -M option to display a list of all installed and enabled Apache modules:

$ apache2ctl -M
Loaded Modules:
 core_module (static)
 so_module (static)
 watchdog_module (static)
...
 reqtimeout_module (shared)
 setenvif_module (shared)
 status_module (shared)

Here, we listed all loaded and currently enabled modules as well as their status (shared or static).

Also, while we can remove or disable shared modules if necessary, we can’t remove or disable static modules since they are integrated into the Apache program.

Alternatively, we can use the apache2ctl -t -D DUMP_MODULES command to get the same results as the earlier ones.

Next, let’s arrange and display our output in alphabetical order by using the apache2ctl -M | sort command:

$ apache2ctl -M | sort
 access_compat_module (shared)
 alias_module (shared)
 auth_basic_module (shared)
 ...
 unixd_module (static)
 version_module (static)
 watchdog_module (static)

In addition to arranging the modules alphabetically, we can filter out a module by its module name using the grep command. The grep command filters out the modules according to the search criteria supplied to it.

$ apache2ctl -M | grep status
 status_module (shared)

Above, we passed the name status as the search criteria in the command and got status_module as the result.

Finally, if we want to, we can stop the server using the apache2ctl command:

$ apache2ctl stop

3. Using the httpd Command

Linux systems use the httpd command line tool to manage the Apache HTTP Server. It’s mainly used in RHEL, CentOS, and Fedora distribution systems. In our case, we’ll briefly discuss how we can use this command to also start, stop and restart the Apache server.

Let’s begin by starting the Apache server by running the httpd start command:

$ httpd start

Once the server starts, let’s display a list of all loaded and enabled Apache modules using the httpd -M command:

$ httpd -M

The command above lists all loaded and enabled apache modules.

We can also use an alternative command to list all loaded and enabled Apache modules:

$ httpd -t -D DUMP_MODULES

Finally, we can shut down the Apache server:

$ httpd stop

It’s crucial to note that some of the commands and utilities above may not be available on our system, depending on the distribution.

4. Conclusion

In this article, we learned the two easiest ways to view Apache-enabled modules using the apache2ctl and httpd commands.

Furthermore, we saw how to use the grep command to filter out specific modules. We also discussed some of the options these commands provide.

Authors Bottom

If you have a few years of experience in the Linux ecosystem, and you’re interested in sharing that experience with the community, have a look at our Contribution Guidelines.

guest
0 Comments
Inline Feedbacks
View all comments