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:
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: