Try the following:
Increase PHP script runtime with Nginx
You can follow the steps below to increase the timeout value. PHP defaults to 30 seconds .:
Changes in php.ini
If you want to change the maximum runtime for php scripts from 30 seconds (default) to 300 seconds.
vim /etc/php5/fpm/php.ini
Set ...
max_execution_time = 300
In Apache, applications working with PHP as a module above would be sufficient. But in our case, we need to make this change in two more places.
PHP-FPM Changes
This is only necessary if you have not already commented on the request_terminate_timeout parameter. It is commented out by default and takes the value max_execution_time found in php.ini
Edit ...
vim /etc/php5/fpm/pool.d/www.conf
Set ...
request_terminate_timeout = 300
Nginx configuration changes
To extend the term for example.com by
vim /etc/nginx/sites-available/example.com location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_read_timeout 300; }
If you want to increase the time limit for all sites on your server, you can edit the main nginx.conf file:
vim /etc/nginx/nginx.conf
Add to http section {..}
http {
Update PHP-FPM and Nginx
Do not forget to do this so that the changes you have made take effect:
service php5-fpm reload service nginx reload
or try
fastcgi_send_timeout 50; fastcgi_read_timeout 50;
fastcgi has its own set of timeouts and checks to prevent it from being disabled when a process is blocked. They will kick if, for example, you set the php runtime limit to 0 (unlimited), and then accidentally create an infinite loop. Or if you used some other application besides PHP, which did not have any of its own timeout protections, and it failed.