Apache mod_PHP et php-fpm

Apache 2.0 Handler/prefork :
(MOD_PHP/PREFORK)

Server MPM:     prefork
  threaded:     no
    forked:     yes (variable process count)
sudo apt-get install -y libapache2-mod-php
sudo a2enmod php7.3
sudo systemctl stop php7.3-fpm
sudo systemctl disable php7.3-fpm
sudo a2dismod proxy_fcgi
sudo a2disconf php7.3-fpm
sudo a2dismod mpm_event/mpm_worker
sudo a2enmod mpm_prefork
sudo systemctl restart apache2

FPM/FastCGI/prefork :
(PHP-FPM/PREFORK)

Server MPM:     prefork
  threaded:     no
    forked:     yes (variable process count)
sudo a2dismod php7.3
sudo apt-get install -y php7.3-fpm
sudo systemctl start php7.3-fpm
sudo systemctl enable php7.3-fpm
sudo a2enmod proxy_fcgi
sudo a2enconf php7.3-fpm
sudo a2dismod mpm_event/mpm_worker
sudo a2enmod mpm_prefork
sudo systemctl restart apache2

FPM/FastCGI/event :
(PHP-FPM/EVENT)

Server MPM:     event
  threaded:     yes (fixed thread count)
    forked:     yes (variable process count)
sudo a2dismod php7.3
sudo apt-get install -y php7.3-fpm
sudo systemctl start php7.3-fpm
sudo systemctl enable php7.3-fpm
sudo a2enmod proxy_fcgi
sudo a2enconf php7.3-fpm
sudo a2dismod mpm_prefork/mpm_worker
sudo a2enmod mpm_event
sudo systemctl restart apache2

FPM/FastCGI/worker :
(PHP-FPM/WORKER)

Server MPM:     worker
  threaded:     yes (fixed thread count)
    forked:     yes (variable process count)
sudo a2dismod php7.3
sudo apt-get install -y php7.3-fpm
sudo systemctl start php7.3-fpm
sudo systemctl enable php7.3-fpm
sudo a2enmod proxy_fcgi
sudo a2enconf php7.3-fpm
sudo a2dismod mpm_event/mpm_prefork
sudo a2enmod mpm_worker
sudo systemctl restart apache2

Le module php7.3 (mod_php) est toujours utilisé avec le MPM prefork.
Le module php7.3 (mod_php) est incompatible avec les MPM event/worker.
Le module php7.3-fpm (php-fpm) peut être utilisé avec les MPM prefork/event/worker.


Quelques commandes utiles

Vérifier l’état du serveur MPM :

sudo apachectl -V
Server version: Apache/2.4.38 (Debian)
Server built:   2019-10-15T19:53:42
Server's Module Magic Number: 20120211:84
Server loaded:  APR 1.6.5, APR-UTIL 1.6.1
Compiled using: APR 1.6.5, APR-UTIL 1.6.1
Architecture:   64-bit
Server MPM:     prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=256
 -D HTTPD_ROOT="/etc/apache2"
 -D SUEXEC_BIN="/usr/lib/apache2/suexec"
 -D DEFAULT_PIDLOG="/var/run/apache2.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="mime.types"
 -D SERVER_CONFIG_FILE="apache2.conf"
sudo a2query -M
prefork

Remarques :

Vérifier l’état d’un module :

sudo a2query -m <modulename>

ex :

$ sudo a2query -m php7.3
No module matches php7.3 (disabled by site administrator)

Vérifier l’état d’une configuration :

sudo a2query -c <configname>

ex :

$ sudo a2query -c php7.3-fpm
php7.3-fpm (enabled by site administrator)

Vérifier l’état d’un site :

sudo a2query -s <sitename>

ex :

$ sudo a2query -s 000-default
No site matches 000-default (disabled by site administrator)

Vérifier les sites actifs :

sudo a2query -s
mysite (enabled by site administrator)

Fermer le menu