There are several ways in which you can set the timeout for php-fpm. In /etc/php5/fpm/pool.d/www.conf
I added this line:
request_terminate_timeout = 180
Also, in /etc/nginx/sites-available/default
I added the following line to the location block of the server in question:
fastcgi_read_timeout 180;
The entire location block looks like this:
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 180;
include fastcgi_params;
}
Now just restart php-fpm and nginx and there should be no more timeouts for requests taking less than 180 seconds.