For the 504 gateway timeout error (PHP FPM) on nginx + fastcgi, we can modify the execution timeout of PHP and nginx.
Configure PHP
Modify php.ini (CentOS path is/etc/PHP. INI). The maximum execution time is 300 seconds
max_execution_time = 300
Modify the PHP FPM configuration file (the CentOS path is/etc/PHP FPM. D/www.conf) and the request timeout is 300 seconds
request_terminate_timeout = 300
Linux PHP restart
https://www.cnblogs.com/niuben/p/13284136.html
Check whether the PHP process starts
ps -ef | grep php-fpm
Kill all PHP FPM processes
pkill php-fpm
Restart PHP
/usr/sbin/php-fpm
If the following error is reported, it means that the PHP FPM folder does not exist. Create a new folder manually, and then restart PHP /usr/SBIN/PHP FPM
ERROR: unable to bind listening socket for address '/run/php-fpm/www.sock': No such file or directory (2)
[04-Nov-2021 11:28:56] ERROR: FPM initialization failed
Create a new missing PHP FPM folder
mkdir /run/php-fpm
Finally, remember to check whether the PHP process has started PS - EF | grep PHP FPM
Configure nginx
Set fastcgi_ read_ Timeout
is added as follows:
location ~ \.php/ {
if ($request_uri ~ ^(.+\.php)(/.+?)($|\?)) { }
fastcgi_pass unix:/run/php-fpm/www.sock;
include fastcgi_params;
fastcgi_param SCRIPT_NAME $1;
fastcgi_param PATH_INFO $2;
fastcgi_param SCRIPT_FILENAME $document_root$1;
fastcgi_read_timeout 300;
}
Check the nignx configuration file
nginx -t
Restart nginx
nginx -s reload