By default, PHP is allowed to execute under 30 sec in most of the web servers, but it varies. When it reaches the limit, it returns a fatal error “Maximum execution time of 30 seconds exceeded”. Sometimes users may need to upload big chunks of files, or need to send mass emails, wordpress theme uploads, etc. In all cases, the most common error is PHP maximum execution limit crossed. In this tutorial, I am going to share how to increase execution time in PHP. So, let’s get started.
How to Increase Execution Time in PHP
I will share how to fix the PHP maximum_execution_time exceeded issue from cPanel as well as from the command line of any VPS or cloud server.
Change PHP max_execution_time in cPanel
To change the maximum execution time limit in cPanel, first go to MultiPHP INI editor under software.
Choose the location where you want to increase the value of maximum execution time.
When you selected the location, where the value needs to be updated. A new window will open, now find the max_execution_time and other php directives you want to update the value.
Now, you can change the PHP maximum execution time value as required. Alternatively, you can update the
.htaccess file to increase execution time in PHP.
To update the php execution time by editing .htaccess, open the htaccess file in cpanel or download the file using FTP. Add the following line at the bottom.
php_value max_execution_time 300
Increase max_execution_time through SSH
If you are using any cloud or VPS hosting, You might have SSH access to the server. In my case, I am using the Ubuntu web server on AWS Lightsail. To update the maximum execution time first, you need to find the PHP INI file on the server. Now edit the PHP INI file using any text editor to change the execution time value.
$ sudo vi /etc/php/7.4/apache2/php.ini
After opening the php ini file, search for max_execution_time and edit the corresponding value.
In this tutorial, you have learned how to increase execution time in PHP. If you have any doubts feel free to contact me, I will definitely try to help you. Also, you can join our elite Facebook group to get direct help from me. If you like this tutorial, please share this article on your social media handle.