Explain the lifecycle of a PHP request when running under PHP-FPM and Nginx.

Last updated 15 June 2026

  • Nginx matches the location, serves static files directly and hands .php requests via fastcgi_pass to the FPM master, which assigns an idle worker from the pool.

  • The worker runs RINIT, populates superglobals, executes the script (opcodes from OPcache if cached) and sends output back over FastCGI to Nginx, which forwards it to the browser.

  • The worker then runs RSHUTDOWN, frees request memory and returns to the pool. The process is reused, not killed.

  • https://dev.to/emrancu/how-php-fpm-works-a-deep-dive-into-fastcgi-process-management-194i
  • https://medium.com/@mgonzalezbaile/demystifying-nginx-and-php-fpm-for-php-developers-bba548dd38f9
  • https://fideloper.com/how-nginx-and-php-fpm-turn-a-web-request-into-code
  • https://octopus.com/devops/software-deployments/php-with-nginx/
  • https://rifatcse09.medium.com/how-nginx-and-php-fpm-manage-millions-of-requests-design-boundaries-and-growth-tactics-14e00a29242f
  • https://nhimg.org/glossary/php-fpm/
  • https://www.youtube.com/watch?v=lh4RnczaATI
  • https://www.akamai.com/cloud/guides/serve-php-php-fpm-and-nginx/
All PHP interview questions