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 a PHP script is allowed to run is defined by the PHP variable max_execution_time. In most shared servers, it will be given a default value of 30 seconds. This post explains how a customer can modify the value of this variable, in case his PHP scripts are supposed to run a little longer. Setting it too high is not recommended.

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. 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 the value to be raised to 60 seconds, ie. 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 The file will 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

Now, your max_execution_time has been changed to 60 seconds and 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 *