I have introduced Nginx + PHP-FPM + APC = a wonderful combination before. Recently, it has been reported that PHP5.4 will likely include the PHP-FPM (PHP FastCGI Process Manager) patch in the kernel. This news came as a great surprise to those who run PHP on the nginx server platform. Maybe you have this question: “What is PHP-FPM? Why should we pay attention to it?”
PHP-FPM is a patch written for the PHP core to handle starting, stopping and restarting FastCGI processes as needed. This is a very critical function, because nginx can only interface with PHP through FastCGI. nginx cannot load all the PHP environment into itself like Apache can. Nginx running PHP through FastCGI has obvious advantages over Apache containing the PHP environment:
◆Low memory usage (because nginx does not need to load the entire PHP environment when running alone).
◆ Easily manage user permissions (because PHP can manage different users in your server process).
◆When PHP crashes, nginx can run normally.
Its downside is that it requires mod_php, nginx, PHP and FastCGI to be installed and set up in contrast. In the past, this installation required co-opting the spawn-fcgi script from the LightTPD project and using it to start the FastCGI process. However, there are some problems with this installation: it is fragile (the process may not restart properly after being stopped) and this installation method is very cumbersome. After installing and configuring nginx, you also need to download LightTPD, set up the script in a targeted manner, set it to start automatically, and then ensure that these are running normally at the same time. If you are used to “bringing doctrine”, using mod_php out of the box, it may convince you that nginx is inferior, especially when you have just upgraded the server to replace the original streamlined platform.
Use PHP-FPM. This patch will embed FastCGI process management functionality into PHP. So when you compile PHP with the FPM patch and select the enalbe-fpm option, nginx will control the start and stop of the PHP process as needed. This saves the previous cumbersome configuration steps. Of course, manually configuring patches and compiling PHP code is still a bit cumbersome for website developers who like to save trouble. Now I want to tell you the surprise that this news brought us: PHP5.4 will include the FPM patch directly into the kernel of the PHP project!
This means you only need to download PHP to compile. You no longer need to set up enalbe-fpm, no longer have to worry about how to synchronize with nginx, and try to adopt the same settings as Apache.
Maybe you have tried to run PHP on nginx platform and cursed at its complexity. I would like to strongly suggest to you to give PHP-FPM a try. Although it still has some problems, it is improving all the time. During this period, maybe you can experience the surprise of a child playing on the street suddenly getting a super cool toy.