Raising Timeouts in Nginx, PHP, or HHVM

If you’ve ever tried to do a an import into WordPress, PHPMyAdmin, or anything else that may take a while processing, you may run into a timeout error. This problem can be traced back to software running your server. If you’re following our setup, you’ll be running Nginx and HHVM. If not, you might be running PHP instead.

We’re setting these timeouts to 600 seconds, or 10 minutes. Be sure to change these variables back to their default after you’re finished.


Gateway 504 error? No more!

For Nginx, we’re going to be changing the fastcgi_read_timeout variable. Depending on your setup, you may find this in different locations. If you’ve followed our tutorial, you can find it at /etc/nginx/fastcgicache.conf. You may also locate it inside /etc/nginx/nginx.conf, or possibly inside of your domain’s virtual host file in /etc/nginx/conf.d or /etc/nginx/sites-available.

fastcgi_read_timeout 600;

NGINX as a Web Proxy for Apache

If you’re using Nginx as a web proxy for Apache, congratulations on your complicated setup. You may need to alter some Apache settings as well. We can’t help you with that because we’re all about Nginx here at VisiStruct. But this will get you going on the Nginx side of things.

Inside of /etc/nginx/nginx.conf, add the following:

proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;


For HHVM, you simply need to edit your php.ini file, which is located at /etc/hhvm/php.ini. You’ll need to change 2 variables here.

max_execution_time = 600
max_input_time = 600


If you’re using PHP, you’ll need to edit two files. Both of these settings need to match.

First, edit your php.ini file. Its location varies depending on Linux version.

max_execution_time = 600

Then you’ll need to edit the www.conf file. Its location also varies by Linux version.

request_terminate_timeout = 600

Jetpack Photon over HTTPS

One of the coolest features of Jetpack is Photon, a free CDN of sorts that hosts your site’s images from the WordPress.com servers. While there’s lots of debate on whether Photon can be a help or a hindrance from a speed and SEO perspective, if you want to use it over an HTTPS connection you’re currently out of luck.

The solution though is quite simple. By adding add_filter( ‘jetpack_photon_reject_https’, ‘__return_false’ );  to your theme’s functions.php  file, Jetpack will now download and feed all of your images over a secure connection. This should help in clearing out any mixed content errors at the very least.

Unfortunately, you may quickly discover that this is a very inconvenient method of doing things as you may need to redo the tweak every time your theme receives an update. Instead, we’ve created a very tiny plugin to accomplish this.


  1. Download the plugin
  2. On your site, go to plugins -> add new
  3. Select “Upload Plugin” towards the top, select the file and hit “Install Now”
  4. Activate the plugin
  5. Done!

That’s it. Now your site can use Jetpack Photon over HTTPS and it’s theme update-proof.