Here is the background.

  • It is a php script that is accessed through a browser.
  • Server: Ubuntu 18.04
  • Web server: Nginx 1.14
  • php: php7.2-fpm

 

The script always stoped on 60 seconds.

The Nginx error log is shown below:

2019/10/23 14:05:18 [error] 996#996: *950 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 135.0.172.188, server: fctu.win, request: “GET /go/do-something.php HTTP/2.0”, upstream: “fastcgi://unix:/var/run/php/php7.2-fpm.sock”, host: “mywebsite.com”

It is a timeout.  I knew it.

In the beginning, I am looking for the php timeout settings.

I tried to add max_execution_time to 360. It doesn’t help.

At last, I add a line into Nginx settings.

fastcgi_read_timeout 180;

Sample code below:

location ~ \.php$ {
    fastcgi_pass unix:/var/run/php7.2-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_read_timeout 180;
    include fastcgi_params;
} 

 

David Yin

David is a blogger, geek, and web developer — founder of FreeInOutBoard.com. If you like his post, you can say thank you here

Leave a Reply

Your email address will not be published. Required fields are marked *