This article describes how to set the maximum execution time for PHP scripts by using the max_execution_time directive in an .htaccess file.
By default, the maximum execution time for PHP scripts is set to 30 seconds. If a script runs for longer than 30 seconds, PHP stops the script and reports an error. You can control the amount of time PHP allows scripts to run by changing the max_execution_time directive in an .htaccess file.
To change the maximum execution time for your PHP scripts, follow these steps:
- Log in to your account using SSH.
- Use a text editor to add the following line to the .htaccess file. Replace 30 with the maximum execution time value that you want to set, in seconds:
php_value max_execution_time 900 - Save the changes to the .htaccess file and exit the text editor.
- To verify that the new setting is active, create a PHP test file that contains the following code in the same directory where the .htaccess file is located: <?php phpinfo(); ?>
- 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.
You can also add other configuration like the following:
1 2 3 4 5 6 |
php_value post_max_size 256M php_value upload_max_filesize 256M php_value memory_limit 128M php_value max_execution_time 900 php_value max_input_time 300 php_value session.gc_maxlifetime 1200 |
Good luck and have a nice day! 🙂