My friend said that the error message 504 gateway time-out has nothing to do with nginx itself. We can solve this problem by adjusting the FastCGI configuration parameters.
.
Modify the PHP-FPM configuration file:
1. Modify max_children according to the system to ensure that there are sufficient PHP-CGI processes available;
Modify the PHP-FPM configuration file to increase the number of PHP-CGI Processes
Modify the number of PHP-CGI processes:
The Code is as follows:
6/usr/local/PHP/etc/php-fpm.conf
Find:
<Value name = "max_children"> 5 </value>
Find the number of PHP Processes Modified according to your memory capacity. Generally, 6 PHP processes are enabled for 128 of the memory, and 16 PHP processes are enabled for 256 of the memory. This ensures high concurrency in PHP.
No 502 error. A process occupies 12m-20m, and the specific number of opened processes depends on the memory size.
Max_children is used to set the number of FastCGI processes. According to official recommendations, servers with less than 2 GB of memory can only enable 64 (www.111cn.net) processes, with more than 4 GB of memory.
The server can start 200 processes.
2. Change request_terminate_timeout to 60 s, so that the timeout time for the PHP-CGI process to process the script is 60 seconds, which can prevent the process from being suspended.
To improve utilization efficiency.
Modify the nginx. conf file as follows:
The Code is as follows:
Fastcgi_connect_timeout 60;
Fastcgi_send_timeout 180;
Fastcgi_read_timeout 180;
Fastcgi_buffers' 4 256 K;
Fastcgi_buffer_size 128 K;
Fastcgi_busy_buffers_size 256 K;
Fastcgi_temp_file_write_size 256 K;
Fastcgi_intercept_errors on;
Then restart your server/etc/init. d/PHP-FPM restart to solve the problem.
From: http://www.111cn.net/sys/nginx/45338.htm
Nginx error prompt: 504 gateway time-out solution