Search code examples
phpnginxprocessoperating-systemwebserver

How can PHP-FPM and nginx interpret php code


Been doing PHP for a while and I still can't understand how can nginx make use of PHP-FPM to interpret PHP code. When a request hits the nginx webserver, does it spawn a process and pass some streams to it? an idle process listening for connections? and how exactly does the data flow?


Solution

  • Nginx and PHP-FPM are both demons or services with their own processes. An Nginx process communicates with a PHP-FPM process either through a TCP port or through a socket. The PHP-FPM demon can be configured in different ways. Either it starts its PHP processes on demand or, if there are many requests on the server, processes can also run permanently to be able to process requests faster.