1

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$ 

2 Answers 2

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

6
  • I get an error about conflicts: peter@peter-HP-Pavilion-15-Notebook-PC:~/websites/test$ sudo a2enmod php7.4 Considering dependency mpm_prefork for php7.4: Considering conflict mpm_event for mpm_prefork: ERROR: Module mpm_event is enabled - cannot proceed due to conflicts. It needs to be disabled first! Considering conflict mpm_worker for mpm_prefork: ERROR: Could not enable dependency mpm_prefork for php7.4, aborting
    – Peter
    Nov 21, 2020 at 14:39
  • 1
    You did not specify this. Please try sudo apt install phpX.Y-fpm and sudo a2enmod proxy_fcgi.
    – BulletBob
    Nov 21, 2020 at 14:40
  • Sorry. Not sure why I didn't specify the error before. Anyway, I tried your suggestion, but still have the same problem, even after a reboot.
    – Peter
    Nov 21, 2020 at 14:54
  • Please post a list of enabled apache modules.
    – BulletBob
    Nov 21, 2020 at 14:57
  • mpm_event negotiation env authz_user alias dir authn_file setenvif status auth_basic proxy authn_core mime authz_core autoindex authz_host deflate reqtimeout proxy_fcgi access_compat filter
    – Peter
    Nov 21, 2020 at 15:03
0

Finally got it fixed. The answer was to disable mpm_event. The PHP module could then be loaded.

sudo a2dismod mpm_event
systemctl restart apache2
sudo a2enmod php7.4

Unfortunately mpm_event could not be reloaded. Attempting to do so returned another error saying there was a conflict with mpm_prefork.

Despite this, apache2 restarted just fine and is working with the very basic PHP pages I have used as tests. Whether or not I'll encounter problems in the future due to mpm_event not being loaded remains to be seen.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .