PHP-FPM via proxy_fcgi

PHP-FPM Through proxy_fcgi, and Why FPM Beat mod_php

mod_php loads PHP into every Apache 129 process. Ubuntu 225 's PHP is built without thread safety, so php8.5.load declares Depends: mpm_prefork, and installing libapache2-mod-php8.5 replaces the default event MPM. Every child then carries PHP even while it sends a PNG, every site runs PHP as www-data in one version, and HTTP/2 is off. PHP-FPM runs PHP in separate pools, and Apache forwards only .php requests to it.

mod_php embeds PHP in every prefork child; event hands PHP to a separate FPM pool
mod_php embeds PHP in every prefork child; event hands PHP to a separate FPM pool

HTTP/2 and HTTP/3 enabled conf-available/php8.5-fpm.conf, which the php8.5-fpm package ships. Wrapped in <IfModule !mod_php8.c> so the two cannot both claim .php, its heart is one line in a FilesMatch: SetHandler "proxy:unix:/run/php/php8.5-fpm.sock|fcgi://localhost" (Unix sockets need 2.4.9 or later). A SetEnvIfNoCase ^Authorization$ line beside it passes the Authorization header, which FastCGI would otherwise drop and token-authenticated APIs need. For a per-site pool with its own user, repeat the block in that vhost with the pool's socket.

FPM does not win everything: on a hello-world script mod_php served 1.6 to 3 times as many requests per second (MPMs and Workers), since each FPM request crosses a socket and Ubuntu's stock pool has five children. Real pages spend milliseconds in PHP and MySQL 524 and hide that hop; prefork's cost per connection they cannot.