What Is PHP-FPM?
How PHP-FPM Runs PHP for a Web Server
PHP-FPM, short for PHP FastCGI Process Manager, is a service that runs PHP code on behalf of a web server. The web server receives a request for a PHP page and passes it to a PHP-FPM worker, which runs the script and returns the output. FastCGI is the protocol that carries requests and responses between the two programs.
PHP-FPM keeps a set of worker processes running and reuses them across requests. Starting a fresh PHP process for every request takes time, so keeping workers ready helps pages respond more quickly. The web server does not need PHP built into it, which separates the two jobs. This split is a common example of the difference between a web server and an application server.
PHP-FPM Compared With mod_php and CGI
PHP can be connected to a web server in several ways, and the choice affects speed and isolation.
- mod_php embeds PHP directly into the Apache web server. It is simple, but PHP code runs with the web server's user and permissions.
- CGI starts a new program for each request. It keeps requests separate but is slow, as explained in what CGI is.
- FastCGI and PHP-FPM keep long-running workers that the web server can reuse, combining speed with separation.
- LSAPI is a similar interface used by LiteSpeed servers.
Most modern hosting setups use PHP-FPM or a close equivalent.
Example: Two Sites on One Server
A hosting server runs two websites. With PHP-FPM, each site can have its own pool of worker processes, and each pool can run under a different system user. If one site is compromised, the attacker's access is limited to that user's files and permissions, which reduces what can be reached on the other site.
Under mod_php, both sites would run PHP under the same web server user, so the separation between them would be much weaker.
Frequently asked questions
Do I need to know PHP-FPM to use PHP?
Most site owners never configure it directly. Hosts usually select the handler that matches their platform and let customers choose a PHP version. Knowing that PHP-FPM exists still helps when reading error logs, diagnosing permission problems or understanding why changes in php.ini sometimes need the service to reload.
Is PHP-FPM faster than mod_php?
It can be, mainly because workers are reused and PHP does not need to be loaded inside every web server process. Results depend on the application, the server and the workload, so there is no universal ranking. For many hosts, the bigger practical benefit is the ability to separate sites by user and run different PHP versions side by side.