Beamtic's logo

Share via:

Module php7 does not exist (a2enmod php7)

How to enable Apache mod_php using a2enmod, and how to find out what the name of the module is.

116 views

Edited: 2020-09-25 07:22

ERROR: Module php7 does not exist!

When trying to enable mod_php using the a2enmod command you may run into a message stating that the module does not exist; this is because the module is named php7.4 (for the latest version) rather than "php7".

To enable mod_php, type the following command:

a2enmod php7.4

The practice of naming various software by the version number is very bad and unintuitive for users. We can hope that we will some day have a "common name" that links to the latest version by default. This would probably avoid confusion caused by version numbers.

Of course, there are also circumstances where you want to install a specific version, such as when you are trying to maintain support for older software that only runs on older versions of PHP; but I think this happens so rarely nowadays that it is more the exception than the rule.

How to find the correct version

I would much prefer that "php" was an alias linked to the latest version of PHP — but you do get used to these things after a while. When using apt to install PHP, and if in doubt, we can simply search for packages that contain "PHP" in their name:

apt search php

To get a list of installed Apache modules, try running the following command:

sudo apt-cache search libapache2*

This should result in something like:

libapache2-mod-php - server-side, HTML-embedded scripting language (Apache 2 module) (default)
libapache2-mod-php7.4 - server-side, HTML-embedded scripting language (Apache 2 module)

Then simply enable the latest version:

a2enmod php7.4

Comments

  1. This article describes configuration issues caused by Apache mischievously picking a default VHOST without telling the user.
  2. How to configure Apache with Multiple Vhost files in Linux.
  3. Find out where to store your custom Apache configuration files in this Tutorial.
  4. In this Tutorial, it is shown how to redirect all HTTP requests to a index.php file using htaccess or Apache configuration files.

More in: Apache