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
Similar Posts:
- PHP FPM and Nginx start normally, page 502 Error [How to Solve]
- Nginx+PHP FastCGI sent in stderr: “Primary script unknown” while reading response head…
- [Solved] Nginx-FastCGI-“Primary script unknown” while reading response header from upstream,
- Solutions to nginx upstream timed out (Two Situations)
- File not found error handling of nginx accessing PHP files, two cases
- Nginx Error: File not found [Use php-fpm to parse PHP]
- nginx: [emerg] getpwnam(“nginx”) failed [How to Fix]
- Wnmp environment configuration (Windows + nginx + MySQL + PHP)
- Nginx an upstream response is buffered to a temporary file,nginx502 Error
- [Solved] Primary script unknown in nginx configuration PHP