Brief introduction
PHP-FPM is actually a patch of PHP source code designed to integrate FASTCGI process management into a PHP package. It must be patch into your PHP source code and can be used after compiling and installing PHP. Now we can download in the latest PHP 5.3.2 source tree to directly integrate the PHP-FPM branch, it is said that the next version will be fused into the main branch of PHP. Relative SPAWN-FCGI,PHP-FPM in the CPU and memory control are better, and the former is easy to crash, must be monitored with crontab, and PHP-FPM does not have this annoyance. PHP5.3.3 has integrated php-fpm, no longer a third-party package. PHP-FPM provides a better way to manage the PHP process, can effectively control memory and process, can be smooth overloaded PHP configuration, more than spawn-fcgi has more advantages, so by the official PHP included. The PHP-FPM can be turned on with the –ENABLE-FPM parameter when the./configure. Use PHP-FPM to control the fastcgi process of php-cgi/usr/local/php/sbin/php-fpm{start|stop|quit|restart|reload|logrotate}--start Start PHP fastcgi process--stop Force terminate PHP fastcgi process--quit smooth termination of PHP fastcgi process--restart Restart PHP fastcgi process--reload Re-smooth loading PHP php.ini--logrotate re-enable log fileFeatured Features
All of these features are implemented in a "no-break" manner. That is, if you do not use them, their presence does not affect the functionality of PHP-they are all "transparent". Error Header range: php.ini option Category: Convenience By default, if the PHP script being accessed contains a syntax error, the user receives an empty "OK" page. This is not convenient. Error header This php.ini option allows an HTTP error code to be generated in this case, such as "http/1.0 550 server made Big Boo", which interrupts the Web Server request and displays a correct error page. If you want to implement such a feature, you need to add a fastcgi.error_header = "http/1.0 550 Server made Big Boo" in php.ini to add a similar in php-5.2.4, But not the same feature: if the php script being accessed contains a syntax error, and display_errors = off, it returns "http/1.0 Internal Server Error" immediately. If you need to set a 503 error, or want to make this behavior independent of the display_errors settings, then you can use Fastcgi.error_header. If you enable PHP-FPM on php-5.2.5 or above, the fastcgi.error_header has a higher priority. Optimized upload support essence: Web server Support type: Optimize this feature as a name, you can speed up processing of large POST requests, including file uploads. Optimization is achieved by writing the request body to a temporary file, and then passing the file name to the FASTCGI protocol instead of the request body. As far as I know, only nginx0.5.9 and above support this function. Obviously, this mode is only available when PHP and Web server are on a single machine. Nginx Sample configuration: Location ~ \.php$ {fastcgi_pass_request_body off;client_body_in_file_only clean;fastcgi_param request_body _file $request _body_file;...fastcgi_pass ...;} There is no need to configure anything in PHP. If PHP receives the parameter request_body_file, it reads the request body and, if not, self-fastcgi the protocolThe request body is read in. In combination with this feature, you can consider using a memory file system for temporary files, such as TMPFS (Linux): Client_body_temp_path/dev/shm/client_body_temp;fastcgi_finish_request ( ) Scope: PHP function Type: Optimizing this feature can improve the processing speed of some PHP requests. If some processing can be done after the page has been generated, you can use this optimization. For example, saving a session in Memcached can be done after the page is handed over to the Web server. Fastcgi_finisth_request (), which can end the response output, the Web server can immediately start handing over to the impatient client, and at this point, PHP can handle many things in the context of the request. For example, save session, convert uploaded videos, handle statistics, and so on. Fastcgi_finisth_request () will trigger the shutdown function to run. Request_slowlog_timeout Range: php-fpm.conf option Category: Convenient This option allows you to track slow-executing scripts and log them together with the call stack. For example, the following settings: <value name= "request_slowlog_timeout" >5s</value><value name= "Slowlog" >logs/slow.log< /value> as you can see in the example, the script runs for more than 5 seconds and is likely due to a slow MySQL response (top backtrace).