When using Nginx as a Web server, you will often encounter 504 Gateway time-out error prompts. After research, basically can be determined that this error in most cases is not related to Nginx itself, the root of the problem is nginx to submit the parsing of PHP to the backend php-fpm process, due to improper configuration of the fastcgi parameters caused by a series of problems.
Through the query related data, summed up the fastcgi configuration parameters adjustment Scheme, for your reference, in detail as follows:
To modify the PHP-FPM configuration file:
1. Change the Max_children to 64 to ensure that sufficient php-cgi processes can be used;
2. Change the request_terminate_timeout to 60s so that the php-cgi process script timeout is 60 seconds, which prevents the process from being suspended and improves utilization efficiency.
Modify the nginx.conf file as follows:
Fastcgi_connect_timeout 60;
Fastcgi_send_timeout 180;
Fastcgi_read_timeout 180;
Fastcgi_buffers 4 256k;
Fastcgi_buffer_size 128k;
Fastcgi_busy_buffers_size 256k;
Fastcgi_temp_file_write_size 256k;
Fastcgi_intercept_errors on;
Nginx appears 504 Gateway time-out solution