Changing the PHP max_execution_time directive
The max_execution_time directive in PHP controls how long a script is allowed to run before it is terminated. By default, this value is set to 30 seconds. If your application requires more time (for example, importing large datasets or running complex processes), you can increase this limit.
???? Why Change max_execution_time?
Section titled “???? Why Change max_execution_time?”- Prevents scripts from timing out during long operations.
- Useful for applications that process large files or perform heavy database queries.
- Helps developers fine‑tune performance and resource usage.
Methods to Change max_execution_time
Section titled “Methods to Change max_execution_time”1. Using a Custom php.ini File
Section titled “1. Using a Custom php.ini File”Create or edit a php.ini file in your application directory:
max_execution_time = 60This sets the maximum execution time to 60 seconds.
2. Using .user.ini
Section titled “2. Using .user.ini”If your hosting environment supports .user.ini, add:
max_execution_time = 603. Using .htaccess
Section titled “3. Using .htaccess”On Apache servers, you can override the directive:
php_value max_execution_time 604. Using cPanel (CageFS Enabled Accounts)
Section titled “4. Using cPanel (CageFS Enabled Accounts)”- Log in to cPanel.
- Go to Software → Select PHP Version → Options tab.
- Locate
max_execution_time. - Set the desired value (e.g., 60, 120).
- Save changes.