Zijidelu Web site Log directory/home/hosts_log
The log file has a corresponding site ID
Zijidelu php-cgi Log Directory/usr/local/php_fcgi/logs
Php-fpm.log
Slow.log
Viewing log files Basically solves the problem, my side of the client site is invaded upload a php DDoS file, of course, if not this issue can be viewed as follows is not a program problem sometimes use file_get_contents function may also lead to CPU 100% OH
In PHP.ini, there is a parameter max_execution_time can set the maximum execution time for a PHP script, but in php-cgi (PHP-FPM), the parameter does not work. The real ability to control the maximum execution time of a PHP script is the following parameters in the php-fpm.conf configuration file:
The timeout (in seconds) to serving a single request after the which the worker process would be terminated
Should be used as ' max_execution_time ' ini option does not stop script execution for some reason
' 0s ' means ' off '
<value name= "Request_terminate_timeout" >0s</value>
The default value is 0 seconds, which means that the PHP script will continue to execute. In this way, when all the php-cgi processes are stuck in the file_get_contents () function, the WebServer of this nginx+php is no longer able to process the new PHP request, and Nginx will return "502 bad Gateway" to the user. Modify this parameter to set a PHP script maximum execution time is necessary, but the symptom does not cure the root causes. For example, change to <value name= "Request_terminate_timeout" >30s</value>, if file_get_contents () gets the content of the Web page is slow, which means 150 A php-cgi process that can handle only 5 requests per second, WebServer is also difficult to avoid "502 bad Gateway".
To achieve a thorough solution, PHP programmers can only get rid of the habit of directly using file_get_contents ("http://example.com/"), but modify it slightly, add a time-out, and implement HTTP GET requests in the following ways. If you find yourself in trouble, you can encapsulate the following code as a function.
<?php
$ctx = stream_context_create (Array (
' http ' => array (
' Timeout ' => 1//Set a timeout in seconds
)
)
);
File_get_contents ("http://www.111cn.net/", 0, $ctx);
?>
Of course, if it's like Dedecms generates HTML pages, the CPU will be 100%.