Select Page


Apache HTTP Server is one of the most popular server softwares found out there. Popular websites such as Ebay, Adobe, and Spotify use Apache behind the scenes. Apache HTTP server has several modules to help you set up your own HTTP server. These modules are controlled (started and stopped) by two scripts provided with Apache, called a2enmod and a2dismod

The a2enmod script is a script that essentially enables the modules in Apache, by creating symlinks. It literally is short for “Apache2 enable module”. However, many people seems to have complained not being able to run the script through their terminals, are are victims to the following error message:

$ a2enmod: command not found

If you’re one of these annoyed users of Apache, I’d probably suggest you not to switch to something else before trying to fix the issue, which I’ll try my best to help you out with, here in this article. 

Why is a2enmod not found?

There could be several possible reasons as to why the script is not found. Firstly, it is possible that Apache is not properly installed in your machine, and even if it is, the path variable may not have been set correctly which directs to Apache when trying to execute the script. It should also be noted that the a2enmod script is stored under the /usr/sbin directory, which is not set to the Environment Path variable of many systems by default. In which case, you’d need to first fix it before you can run the script itself.

The following sections will discuss the possible fixes for the error in detail. 

Properly install Apache

The very first thing you’d want to ensure is that the Apache HTTP Server software is itself properly installed in your system. To install the package in your system, you’d need to use your Linux Distribution’s package manager. Different distributions use different package managers, so you need to find out which one you need for your system. The commands required to install the package in the most commonly used Linux distributions are mentioned below:

Arch Linux

$ sudo pacman -Syu
$ sudo pacman -S apache


$ sudo apt-get update
$ sudo apt-get install apache2


$ sudo apt-get update
$ sudo apt-get install apache2


$ sudo yum makecache
$ sudo yum install httpd


$ sudo dnf makecache
$ sudo dnf install httpd


$ sudo dnf makecache
$ sudo dnf install httpd

The first line of commands are necessary for updating your system and it’s repositories. Oftentimes, you might be unable to install any packages properly if the repositories aren’t up to date. The second line of command is responsible for installing the Apache HTTP Server application in your machine.

Even if you might already have the package installed, it is a good idea to use the commands for reinstalling the packages, in case of the application being corrupted in some way, or the PATH variable not being able to trace for the package. 

Also, if you have previously installed Apache from source code instead of using a package manager, and used a different directory to install it other than in /usr/bin, you need to add that directory to the PATH variable. 

Fix the path variable

Once you’ve made sure that the Apache HTTP Server has been preperly installed and is set up for use, but are unable to run the script nevertheless, you now need to ensure that the /usr/sbin directory is listed in your PATH Variable, because that is where the script is located. In many systems, this directory is not set to the PATH variable by default, so you need to set it up manually. 

If you’re using the Bourne Again Shell, then you first need to open up the configuration file called bashrc, which should be hidden and located in your home directory. You may use a terminal text editor like nano to do so:

$ nano ~/.bashrc

Inside this file, append the following line of code:

$ export PATH=$PATH:/usr/sbin

Now save and exit the file by pressing Ctrl + O, then Enter, followed by Ctrl + X. Restart the terminal and try checking whether you’re able to run the script.

Use sudo when running a2enmod

Besides fixing the path variable, you should ensure that you use sudo when running the script. The sudo command will give you user privileges to run scripts and all that regular users in your system might not be able to. If your user does not have permission to run apps and scripts from the /usr/sbin directory, then you need to give a user administrative privileges to run them. Simply include sudo in your command like this:

$ sudo a2enmod

You can also login to the root user and run the script from there, which won’t require you to use the sudo command. Ro switch to the root user, use the following command:

$ sudo su

Now enter the password for your root user, and once you’re inside, you should be able to directly use the script without needing to use sudo. 

However, it is discouraged to login as the root user unless you absolutely need to, as you might end up easing your whole system if you’re not careful when executing stuff in your Linux Machine!