Contents...
Often you have seen the ” 504 Gateway Time-out ” error on your web page if you have large WordPress setup or a server with limited resources.
You can fix this issue increasing max_execution_time in Nginx or php/php-fpm php script execution time.
Set or Increase “max_execution_time” in Nginx
To increase or set max_execution_time in Nginx you will need to update your nginx vhost conf file. For example I am updating my example.com vhost file. You have to setup fastcgi_read_time as show below.
# 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 60;
}
You can also increase time limit for all sites means for all vhost on your server, you will need to edit main nginx.conf file.
# vim /etc/nginx/nginx.conf Add following in http{..} section http { #... fastcgi_read_timeout 60; #... }
Here I have set to 60 second. Please not down default value is 30 second by default so I have increase it to 60 seconds.
Reload Nginx
Don’t forget to do this so that changes you have made will come into effect:
# service php5‐fpm reload # service nginx reload
Set or Increase “max_execution_time” in PHP
You can change the max execution time limit for php scripts for 30 seconds (default) to 60 seconds you have to update your php.ini file like below.
# vim /etc/php5/fpm/php.ini
Set..
max_execution_time = 60
In Apache, it is sufficient to set max execution time in php.ini, but in our case we need to make this change at 2 more places.
Set or Increase “max_execution_time” in PHP-FPM
This is only needed if you have already un-commented request_terminate_timeout parameter before. It is commented by default, and takes value of max_execution_time found in php.ini file.
You will need to edit.
# vim /etc/php5/fpm/pool.d/www.conf
Set..
request_terminate_timeout = 60
That’s all, I hope this tutorial will help you.
If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.
Leave a Comment