Understanding PHP�s max_execution_time
The max_execution_time setting in PHP controls how long a script can run before the server forcefully stops it. By default, many hosting environments limit this to 30 seconds, which may not be sufficient for resource-intensive tasks like running backups, imports, or complex plugin operations.
Why Adjust max_execution_time?
Certain plugins or site operations�especially those involving backups, data imports, or scanning tools�require more time to complete. If the script exceeds the server�s time limit, it will be terminated early, potentially causing errors or incomplete actions.
Setting this value higher gives those processes a better chance to finish successfully.
Method 1: Editing php.ini
If you have direct access to the server’s php.ini file:
- Locate the
php.inifile. This is often found in the root of your server�s PHP configuration or under a specific version directory. - Open the file in a text editor.
- Find the line that looks similar to:
max_execution_time = 30(It may have another value set) - Change it to:
max_execution_time = 300 - Save the file
- Restart the PHP server
Method 2: Using cPanel (MultiPHP INI Editor)
If your hosting provider offers cPanel with the MultiPHP INI Editor:
- Log in to your cPanel dashboard.
- Go to the Software section and open MultiPHP INI Editor.
- In �Basic Mode,� select the domain or directory for your site.
- Scroll down to the
max_execution_timesetting. - Increase the value (e.g., to
300). - Click Apply to save your changes.
When to Use This Method
- You are on shared hosting and do not have direct access to
php.ini. - Your host provides cPanel and enables PHP configuration changes through the UI.
Method 3: For Local Environments (MAMP, etc.)
If working in a local development environment like MAMP:
- Open your MAMP directory.
- Navigate to:
MAMP > conf > php > [version folder] > php.ini - Open
php.iniin a text editor. - Locate:
max_execution_time = 30 - Change to:
max_execution_time = 300 - Save the file and restart MAMP.
Tip for MAMP Users
Ensure you�re editing the correct PHP version used by your site in MAMP. You can verify the active version from the MAMP start screen.
Additional Notes
- Some managed hosting providers override local
php.inisettings. In these cases, changing the value through cPanel or contacting support may be required. - After adjusting the value, verify it has been applied by checking your site’s PHP info output (e.g., using
phpinfo()or a plugin that shows server settings).