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.

10210 views
d

By. Jacob

Edited: 2022-08-01 07:23

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

Tell us what you think:

Mike

I have all those modules, but a2enmod php7.4 tells me that it didn't find php7.4 module, despite the fact that he is in apache list of modules

Peter

Ditto to Mike. Same response - Module php7.4 does not exist!

Michele Clark

I had the same issue, ended up purging libapache2-mod-php7.4 then reinstalling it - it let me run the a2enmod then

  1. This article describes configuration issues caused by Apache mischievously picking a default VHOST without telling the user.
  2. In this Tutorial, it is shown how to redirect all HTTP requests to a index.php file using htaccess or Apache configuration files.
  3. How to have files uploaded through SFTP correctly inherit the group permissions of the parent directory.

More in: Apache