deployment and operations

PHP-FPM

PHP-FPM is a common way to serve PHP web requests. A web server such as Nginx or Apache accepts HTTP traffic and forwards PHP work to an FPM socket or port. FPM keeps worker processes ready so the operating system does not need to start a fresh PHP process for every request.

Understand The Pool

  • Understand the path from web server to FPM socket or port.
  • Configure pools with deliberate user, group, environment, and process settings.
  • Use logs and slowlog settings during diagnosis.

Diagnose The Serving Path

  • Verify config syntax with platform tooling.
  • Check service status and request handling.
  • Reload gracefully after config change.

Common Failure Modes

  • FPM pool separation is not complete security isolation.
  • Too few workers queue requests; too many exhaust memory.
  • Web server and FPM timeouts can disagree.

Pool Sketch

[www]
user = www-data
group = www-data
listen = /run/php/php-fpm.sock
pm = dynamic
pm.max_children = 12
request_slowlog_timeout = 5s
slowlog = /var/log/php-fpm/www-slow.log

When PHP pages fail but static files still work, check the path between the web server and FPM: socket permissions, service status, pool logs, PHP logs, timeouts, and slow-request diagnostics. Verify configuration syntax before a graceful reload, then exercise a real HTTP request. CLI PHP can work while FPM is misconfigured because they are separate runtime contexts.

Practice

Practice: Review An FPM Pool

Review an FPM pool for a small web application. Explain what you would inspect when static assets load but every PHP route returns an upstream error.

Requirements

  • Understand the path from web server to FPM socket or port.
  • Configure pools with deliberate user, group, environment, and process settings.
  • Use logs and slowlog settings during diagnosis.
  • Verify config syntax with platform tooling.
  • Check service status and request handling.
  • Reload gracefully after config change.
Show solution

Trace the request from the web server to the configured FPM socket or port. Confirm that the FPM service is running, the socket exists, and the web-server user can reach it. Then inspect the pool and PHP logs rather than testing only php on the command line.

Check configuration syntax before reloading FPM gracefully. After the reload, send a real HTTP request and verify the response plus logs. Treat pm.max_children as a measured capacity setting, not a value to copy blindly.