Setting Php max_execution_time on shared host environments



The back story ...

wordpress-backupI recently developed a website for a customer who was having issues with the wordpress backup plugin Duplicator.

The site was around 300mb in size and, on the shared hosting plan that the site was on, the plugin would time out after 120 seconds which was not enough for the plugin to complete the process of archiving the site.

Trying to set the php variable max_execution_time to a suitable time in a local php.ini file seemed to make no difference and the plugin continued to fail leaving half completed archives in its tmp directory.

I contacted the host ISP's support, who informed me that the server had a hard limit of 120 seconds and no matter what max_execution_time was set to in the local php.ini file, the server would kill off the process anyway after 2 minutes. They initially said there was nothing more that could be done about this.

The ISP was reluctant to supply a work around for this but eventually hinted at a .htaccess modification that would allow the process to complete even after the 120 second restriction was exceeded.

The ISP also warned me that their policy on fair use limited PHP scripts to 180 seconds and that if I was found to be abusing that, then my account may be suspended. You have been warned ! :).

In the final analysis Zuver tech support did come to the party and have allowed me to do this. You should check if its ok with your ISP before trying this.

I should point out that the ISP's have a point. PHP scripts fired off by the front end normally complete in millisecond times or at most a second or two, and a script running for more than 2 minutes is hogging valuable resources, particularly in a shared hosting environment. Back up is normally a process best done offline and not while a user is waiting for a response from the front end.

However, that said, WordPress users don't want to know about configuring backup scripts or modperl / apache solutions or even the provided cpanel automated backup solutions. They just want an easy to use WordPress plugin that will do it all for them, that can easily be installed and configured in the WordPress plugin environment that they are already familiar with.

My ISP was (sister company of VentraIp) and the backend was linux / apache .

Your mileage may vary depending on your hosts server environment.

Leave a reply