PHP-FPM (FastCGI Process Manager) is the service that runs PHP code for web servers. The web server, usually Nginx, receives a request for a PHP page and passes it to PHP-FPM, which runs the code and sends back the finished HTML. WordPress, Drupal, Laravel and most PHP software run this way.
Pools and workers
PHP-FPM keeps a pool of worker processes ready. Each worker handles one request at a time. Pool settings decide how many:
pm = dynamic
pm.max_children = 12
pm.start_servers = 3
pm.min_spare_servers = 2
pm.max_spare_servers = 5
pm.max_children is the important one: the most requests PHP can handle at once. Too low and visitors queue at busy times; too high and the server runs out of memory. Each site on a server can have its own pool, running as its own user, which keeps sites separated.
Where things are
| Debian and Ubuntu | AlmaLinux, Rocky, RHEL | |
|---|---|---|
| Service | php8.3-fpm (version in the name) | php-fpm |
| Pool files | /etc/php/8.3/fpm/pool.d/ | /etc/php-fpm.d/ |
| Socket | /run/php/php8.3-fpm.sock | /run/php-fpm/www.sock |
When it goes wrong
If PHP-FPM stops, or Nginx points at the wrong socket, visitors see 502 Bad Gateway. When every worker is busy, the log says server reached pm.max_children and visitors see slow pages or 503. Slow PHP leads to 504 Gateway Timeout.