Apache does not interpret php code

I have recently had to uninstall and reinstall a LAMP stack on Ubuntu 20.10. Everything appears to go well, except that PHP code is not interpreted. It appears that the PHP module is not loaded.

The restart at the end of the sequence below made no difference.

So it looks as though I need to add something to an apache config file, but I don't really understand the way the config files work on Ubuntu.

Can anyone help?

Leyendo lista de paquetes... Hecho
Creando árbol de dependencias       
Leyendo la información de estado... Hecho
Se instalarán los siguientes paquetes NUEVOS:
  libapache2-mod-php php
0 actualizados, 2 nuevos se instalarán, 0 para eliminar y 0 no actualizados.
Se necesita descargar 5,676 B de archivos.
Se utilizarán 30.7 kB de espacio de disco adicional después de esta operación.
Des:1 http://gb.archive.ubuntu.com/ubuntu groovy/main amd64 libapache2-mod-php all 2:7.4+76 [2,904 B]
Des:2 http://gb.archive.ubuntu.com/ubuntu groovy/main amd64 php all 2:7.4+76 [2,772 B]
Descargados 5,676 B en 2s (2,728 B/s)
Seleccionando el paquete libapache2-mod-php previamente no seleccionado.
(Leyendo la base de datos ... 530220 ficheros o directorios instalados actualmen
te.)
Preparando para desempaquetar .../libapache2-mod-php_2%3a7.4+76_all.deb ...
Desempaquetando libapache2-mod-php (2:7.4+76) ...
Seleccionando el paquete php previamente no seleccionado.
Preparando para desempaquetar .../php_2%3a7.4+76_all.deb ...
Desempaquetando php (2:7.4+76) ...
Configurando php (2:7.4+76) ...
Configurando libapache2-mod-php (2:7.4+76) ...
peter@peter-HP-Pavilion-15-Notebook-PC:~/websites/test$ a2query -m php
No module matches php
peter@peter-HP-Pavilion-15-Notebook-PC:~/websites/test$ a2query -m php7
No module matches php7
peter@peter-HP-Pavilion-15-Notebook-PC:~/websites/test$ php -v
PHP 7.4.9 (cli) (built: Oct 26 2020 15:17:14) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.9, Copyright (c), by Zend Technologies
    with Xdebug v2.9.6, Copyright (c) 2002-2020, by Derick Rethans
peter@peter-HP-Pavilion-15-Notebook-PC:~/websites/test$ a2query -m php7.4
No module matches php7.4
peter@peter-HP-Pavilion-15-Notebook-PC:~/websites/test$ apachectl configtest
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
Syntax OK
peter@peter-HP-Pavilion-15-Notebook-PC:~/websites/test$ sudo systemctl restart apache2
peter@peter-HP-Pavilion-15-Notebook-PC:~/websites/test$ 

Solution 1:

You need to install PHP first via sudo apt install libapache2-mod-phpX.Y (in case it's missing) and then enable it with sudo a2enmod phpX.Y. Restart apache2 and PHP should work fine.

In case you want to enable HTTP2 support: sudo apt install phpX.Y-fpm and sudo a2enmod proxy_fcgi