The first is to change several configurations of the PHP-FPM:
/www/wdlinux/php/etc/php-fpm.conf
/www/wdlinux/etc/php-fpm.conf Max_children from the previous 10 to the current 30, so that there is sufficient php-cgi process can be used;
Change the request_terminate_timeout from the previous 0s to 60s, so that the php-cgi process script timeout is 60 seconds, preventing the process from being suspended and increasing utilization efficiency.
Open/usr/local/php/etc/php-fpm.conf
Increase the following two parameters (according to the server actual situation, too large is not good)
5120
600
504 Timeout
Send_timeout 60;
Fastcgi_buffers 8 128k;
In/www/wdlinux/nginx/conf/nginx.conf
To add and adjust these two parameters to try, with other solutions
One, fastcgi buffer set too small
Error, first to find the Nginx log file, the directory is/var/log/nginx, the following error found in the log.
2013/01/17 13:33:47 [ERROR] 15421#0: *16 upstream sent too big header while reading response header from upstream
Looked at the data, to the effect that the nginx buffer has a bug caused by the page consumption of our site may be too large.
On the Internet to find a solution, in the foreign site saw a way to increase the buffer, thoroughly solve the problem of Nginx 502 bad Gateway. The method is as follows:
HTTP {
...
Fastcgi_buffers 8 16k;
Fastcgi_buffer_size 32k;
...
}
Increase the above two configuration items by yourself, depending on the server's already web site.
Second, proxy buffer set too small
If you are using a nginx reverse proxy, if the header is too large to exceed the default 1k, it will cause the above upstream sent too big header (in the end, nginx the external request to the backend processing, the back end of the header is too large, Nginx processing can lead to 502.
server {
Listen 80;
server_name *.lxy.me;
Location/{
############## #添加这3行
Proxy_buffer_size 64k;
Proxy_buffers 32k;
Proxy_busy_buffers_size 128k;
############## #添加这3行
Proxy_set_header Host $host;
Proxy_set_header X-real-ip $remote _addr;
Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
............
}
Third, the default php-cgi number of processes set too little
There are 502 problems with the installation process, typically because the default php-cgi process is 5, which can result in 502 due to insufficient phpcgi processes and needs to be modified/usr/local/php/etc/php-fpm.conf Max_ The children value is increased appropriately. It is also possible that the max_requests value is not enough. It is important to note that the attached configuration items occupy a large amount of memory, which is set according to your server configuration. Otherwise, it may play a reverse effect.
Four, PHP execution timeout www.111cn.net
PHP execution Timeout, modify/usr/local/php/etc/php.ini change Max_execution_time to 300
Five, nginx wait time timeout
Part of the PHP program execution time exceeds the Nginx wait time, can appropriately increase the timeout time of fastcgi in the nginx.conf configuration file
HTTP {
Fastcgi_connect_timeout 300;
Fastcgi_send_timeout 300;
Fastcgi_read_timeout 300;
......
}