The default PHP’s execution time (max_execution_time) is 30 seconds. This is the time limit for a PHP script for how many seconds the script can use 100% of CPU time.
It is possible to increase the time limit for a PHP script using the function set_time_limit()
or by modifying the PHP configuration file php.ini or .user.ini.
Using the function set_time_limit() in a PHP script
Add the set_time_limit()
function to the beginning of the required PHP file or before the code causing the problem with required number of seconds:
set_time_limit(60);
Using a global php.ini or directory-specific .user.ini file
max_execution_time = 60
By using a global php.ini file to increase the time limit will affect all virtual hosts of main and subdomains.
The local .user.ini file affects scripts located in the same directory and its subdirectories.
If a PHP script is taking more CPU time than the allowed limit, then similar error message will be generated:
PHP Fatal error: Maximum execution time of 30 seconds exceeded in /data01/virt1234/domeenid/www.example.com/htdocs/index.php on line 5