How to increase PHP Max Execution Time

Sometimes you might have noticed that certain PHP scripts that you wrote are not working as desired. A very common errror message is Fatal error: Maximum execution time of 30 seconds exceeded.  The cause is the PHP restriction on the directive max_execution_time.

The amount of time (in seconds) a PHP script is allowed to run is defined by the PHP variable max_execution_time. In most shared servers, the default configuration is 30 seconds. This article explains how a customer can modify the value of this variable, if they need their PHP scripts to run for longer. We recommend not setting it very high.

How to solve Fatal error: Maximum execution time of 30 seconds exceeded

First, login to your cPanel account using your cPanel username and password. If you forgot the password, you can reset it any time using the ‘Reset Password’ option under the login box.



Once logged in and you are in the cPanel dashboard, go to Software -> Select PHP Version option.



It will take you to a page which lets you choose the version of PHP you would like to run along with the extensions you would like to enable or disable. Basically, to the top right of the page, there is another option ‘Switch to PHP Options’. Click on it.



Now, you will see a list of PHP variables along with the values associated to each variable. Check the value of max_execution_time, mostly it will be the default 30. Click on it and you can enter the new value you require. Suppose, I need to increase the value to be raised to 60 seconds (1 minute). I will enter 60 in the box and hit ‘Apply’. Scroll to the bottom and click on the ‘Save’ button for the changes to get into effect.




To confirm the changes, I will upload a file, say named info.php, to the public_html folder of my domain That is, such file must have the following contents in it:


Now take a browser and try accessing the file as Remember to change to the domain name you are using. Search for max_execution_time in the page displayed and check the value listed. I can see that it has changed to 60 seconds.


Max Execution Time in phpinfo

At this point your max_execution_time is changed to 60 seconds. Now, your PHP scripts can run for 1 minute without interruption now.


Leave a Reply

Your email address will not be published. Required fields are marked *