Resolve a 502 Bad Gateway error encountered by Nginx + PHP (FastCGI)

  • 2020-05-06 12:12:12
  • OfStack

I asked you to follow the following two steps to solve the problem. Finally, in step 2, I increased the timeout time of FastCGI to 300. Problem solved:
PS: relatively envy thunder Web server, 16G memory.

1. Check the current PHP FastCGI process count:
netstat -anpo | grep "php-cgi" | wc -l
If the actual number of FastCGI processes used is close to the preset number of FastCGI processes, then the number of FastCGI processes is insufficient and needs to be increased.

2. The execution time of some PHP programs exceeds the waiting time of Nginx, so the timeout time of FastCGI in nginx.conf configuration file can be appropriately increased, such as
 
...... 
http 
{ 
...... 
fastcgi_connect_timeout 300; 
fastcgi_send_timeout 300; 
fastcgi_read_timeout 300; 
...... 
} 
...... 

Related articles: