PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation. It is specifically designed to significantly enhance the speed of PHP applications, and it is extremely useful for sites that endure heavy loads. PHP-FPM maintains pools (workers that can respond to PHP requests) to accomplish this performance boost.
The PHP-FPM model differs from the standard PHP model in several ways:
- Process Management: PHP-FPM is a daemon process that runs a FastCGI server on the socket or port you configure, and it dispatches CGI requests to worker processes it manages. This saves the overhead of starting the PHP interpreter for every request, and thus it is faster.
- Adaptive Process Spawning: One of the biggest advantages of PHP-FPM is the fact that it uses an adaptive process spawning method. This makes it more efficient in terms of resource usage.
- Security: PHP-FPM allows for better security since there’s a separate user for the PHP processes, thereby improving the isolation between different PHP applications running on the same server.
- Advanced Features: PHP-FPM includes a variety of advanced features, such as graceful stop and start, emergency restart in case of accidental opcode cache destruction, accelerated upload support, and more.
To use PHP-FPM, you need to install it, then configure your web server (like Nginx or Apache) to pass PHP requests to PHP-FPM. It’s widely used in PHP deployments and especially popular in high-traffic websites due to its ability to manage high loads.
It should be noted that PHP-FPM is especially useful when used in conjunction with a web server that doesn’t have PHP embedded, such as Nginx. In the case of Apache, it has the ability to embed PHP through mod_php but can also use PHP-FPM if desired. The choice between the two can depend on a number of factors, including specific performance needs and the available server resources.