In this article I will describe how to set the maximum execution time for PHP scripts by using the max_execution_time directive in an .htaccess file.
I assume that you have already set up a custom .htaccess file. Please setup a custom .htaccess file if you have not setup it.
Setup Max Execution Time For PHP Scripts
By default, maximum execution time for PHP scripts is set to 30 seconds. If PHP scripts runs longer than 30 seconds, PHP stops the script and report an error. You can change max execution time using the max_execution_time directive in an .htaccess file.
Follow the below steps to change the maximum execution time for PHP scripts:
1. login to your server using SSH.
2. Open the .htaccess file in any text editor to add the following line. Replace 30 with the maximum execution time value that you want to set.
# vim .htaccess ..... php_value max_execution_time 30 ..
3. Save and close the .htaccess file.
4. Verify that new setting is active or not, you will need to create a PHP test file that the contains the following code in the same directory where .htaccess file is located.
# vim phpinfo.php <?php phpinfo(); ?>
Save and close.
5. Load the test file in your web browser, and then search for the name of the directive. The Local Value column should display the new setting that you specified in the .htaccess file.