How To Change PHP Time Limit In WordPress: 4 Easy Ways
Bulletproof Backups for Your WordPress Website
Fortify your business continuity with foolproof WordPress backups. No data loss, no downtime — just secure, seamless operation.
One minute you’re updating a plugin or backing up your site, and the next, you’re staring at a “Maximum execution time exceeded” error. Now you’re confused: what is this error and why did this occur?
This error isn’t just annoying—it’s a serious roadblock. It stops your workflow and leaves important tasks unfinished. You might feel stuck and unsure of what to do next.
But there’s good news: you don’t have to live with this issue. This error occurs because your PHP time limit is too low for the task. By adjusting the PHP time limit or even updating your PHP version in WordPress,you can fix these interruptions.In this guide, we’ll show you how to do this and get your WordPress site running smoothly again.
TL;DR: Adjusting the PHP time limit in WordPress can prevent frustrating timeout errors during heavy load tasks. You can modify this limit through your hosting provider, or by editing files like wp-config.php, .htaccess, or php.ini. Always back up your site using a robust plugin like BlogVault before making changes to ensure safety.
Understanding the PHP time limit in WordPress
The PHP time limit in WordPress decides how long a task can run before the server stops it. Think of it as a timer for tasks to ensure they don’t run for too long and hog your site’s resources.
Why it matters
Prevents overuse: Adjusting the PHP time limit by decreasing it prevents tasks from using excessive server resources, ensuring that everything else runs smoothly.
Handles large tasks: Backup plugins like UpdraftPlus are very resource-intensive. UpdraftPlus backups can take a significant amount of time to complete. Especially for websites with extensive data and large files. Increasing the PHP time limit helps ensure these tasks are completed successfully without timing out.
Avoids timeouts: Adjusting the PHP time limit prevents tasks from timing out, which means they won’t be abruptly stopped because they took too long to run. When tasks time out, it can disrupt your work and lead to errors, especially with heavy tasks.
Setting a balanced PHP time limit is key. It ensures your website runs smoothly. Knowing how to set the right time limit helps keep everything working perfectly.
Some of the methods to change the PHP time limit need you to edit core files. Ensure you take a full-site backup before proceeding. Having a backup ensures you can restore your site if something goes wrong.
A) Use web host settings to change the PHP time limit
Most hosting providers allow you to modify your PHP time limit. If your provider supports this, it’s the safest method to choose. We will walk you through this using Cloudways as an example:
1. Navigate to your server: Start by logging in to your Cloudways account and navigating to your site’s server.
2. Find settings and packages: Look for a section called Settings and Packages on the left panel and click on it.
3. Enter the new value: Under the Execution Limit section, enter the new value you want in seconds. You can increase it to give your tasks more time to complete.
Cloudways sets your execution time to 300 seconds by default. The default PHP time limit can vary depending on the hosting provider or specific server configuration.
Note: The lowest PHP limit you can set is 1 second. The highest PHP limit you can set is 0, which means the script can run indefinitely.
B) Edit the wp-config.php file to change the PHP time limit
Editing the wp-config.php file is another way to change your PHP time limit. But caution is key here! Always take a backup of your site first. Even tiny errors can crash your site.
1. Access the root directory: Use an FTP client like FileZilla or your hosting provider’s file manager to access your WordPress installation’s root directory. This is usually named public_html or www.
2. Edit the wp-config.php file: Locate the wp-config.php file and open it. Edit the file within the FTP client if you can or use a text editor like Visual Code Studio.
Insert the following line of code towards the end of the file, but before the comment line that says, That’s all, stop editing! Happy blogging!
set_time_limit(X);
Replace X with your desired value in seconds. For example, set_time_limit(300); for 300 seconds.
Once you’re done editing, save the file and upload it back to your server.
3. Test the new settings: Finally, test your site to ensure the new time limit is in effect. Run the tasks that previously caused timeouts to check if they are now completed successfully.
C) Edit the .htaccess file to change the PHP time limit
1. Access your root directory: Use an FTP client like FileZilla or your hosting provider’s file manager to access your WordPress installation’s root directory, usually named public_html or www.
2. Unhide the .htaccess file: The .htaccess file is hidden by default. You need to unhide it to make changes. Navigate to the Server menu and click on the option that says Force showing hidden files.
3. Edit the .htaccess file: Once you can see the .htaccess file, open it for editing. Add the following line of code at the end of the file:
php_value max_execution_time X
Replace X with the number of seconds you want as your new time limit. Save the modified .htaccess file and upload it back to the server.
4. Test the new settings: Test your site to ensure the new time limit is in effect. Run the tasks that previously caused timeouts to verify if they are now completed successfully.
D) Edit the php.ini file to change the PHP time limit
1. Access the php.ini file: First, you need to find your server’s php.ini file. It’s usually located in the root directory or a subdirectory like etc or php. You can use FileZilla or your hosting provider’s file manager to get there.
2. Edit the PHP.ini file: Once you locate the php.ini file, open it for editing. If you’re using FileZilla, you can edit the file within the client.
Look for a line that says max_execution_time. It usually looks like this:
max_execution_time = X
If you find it, you can edit its value. If it doesn’t exist, you need to add it. Replace X with the number of seconds you want the new time limit to be.
3. Test the new settings: Test your site to ensure the new time limit is working. Run the tasks that used to cause timeouts to see if they now finish successfully.
When should you change your PHP time limit?
Knowing when to change your PHP time limit can save you a lot of headaches. Here are some situations where you might need to increase it:
Frequent timeouts: You’re receiving a “maximum execution time exceeded” error during tasks like plugin or theme updates. It’s a sign you need more time.
Large data operations: If you import or export large datasets, like products, posts, or user information, a higher PHP time limit can help these tasks finish without errors.
Backups and restores: Running large backup or restore operations? These tasks need plenty of time to complete, especially if they involve a lot of data. Unless of course, you’re using a service like BlogVault.
Bulk actions: Performing bulk operations such as compressing images, sending emails, or managing users can be time-consuming and may require a longer PHP time limit.
Media handling: Managing or processing large media files or extensive media libraries takes time. A higher PHP time limit can prevent these tasks from failing.
Database maintenance: Intensive database operations like optimization, cleaning, or migrations need extra time to run smoothly.
Custom scripts: Executing custom PHP scripts or cron jobs can take a long time. Increasing the PHP time limit can help them complete without timing out.
Complex website tasks: Handling e-commerce transactions, large-scale content updates, or other complex operations on your site often need more time than the default limit offers.
Downgrading PHP Version
If you encounter persistent issues even after adjusting the PHP time limit, it might be necessary to roll back to a previous PHP version. This is particularly relevant if your plugins or themes require a specific version for compatibility.
Parting thoughts
Modifying the PHP time limit is essential for smooth WordPress operations. Adjusting this setting can help prevent timeouts during heavy load tasks.
You can change the PHP time limit by editing files like wp-config.php, .htaccess, or php.ini— methods that require a certain level of technical proficiency.
Alternatively, you can adjust the PHP time limit through your hosting provider’s control panel, which is more user-friendly and suitable for those less comfortable with code.
If you still run into problems, don’t hesitate to contact your hosting provider’s support team for more help. They can offer additional insights and solutions.
FAQs
Will changing the PHP time limit affect my website’s security?
Changing the PHP time limit in itself does not directly affect your website’s security. However, setting it to an excessively high value or unlimited can increase the risk of long-running scripts consuming excessive server resources, which could potentially be exploited.
Is it safe to change the PHP time limit in WordPress?
Yes, it is generally safe to change the PHP time limit. However, always take a backup of your site before making any changes to core files to avoid potential issues.
What is the maximum execution time for WordPress PHP?
The default maximum execution time for WordPress PHP is usually set to 30 seconds, but it can be increased to a higher value if needed.
What happens if the PHP time limit is too low?
If the PHP time limit is too low, tasks that require more time to complete will fail, resulting in errors like “maximum execution time exceeded”. This can disrupt your site’s functionality and user experience.
Where are the PHP settings in WordPress?
PHP settings in WordPress can be found in several key files within your WordPress installation. These files include wp-config.php, .htaccess, or php.ini. all of which are typically located in the root directory of your WordPress installation.
Tags:
Share it:
You may also like
Repair WordPress Installation In 6 Simple Ways
Is your WordPress site currently facing errors, running slower than usual, or even completely offline? If you’re struggling with the white screen of death, database connection errors, or malware warnings,…
How to Take a cPanel Backup
Every website admin knows that backing up your website is important. The worst case scenario is not being able to restore a crashed or hacked site. Good backups are like…
How Often To Backup A Site
In today’s digital age, safeguarding your data is more crucial than ever. There is also an abundance of advice on when to take website backups and how often to take…
How do you update and backup your website?
Creating Backup and Updating website can be time consuming and error-prone. BlogVault will save you hours everyday while providing you complete peace of mind.
Updating Everything Manually?
But it’s too time consuming, complicated and stops you from achieving your full potential. You don’t want to put your business at risk with inefficient management.
Backup Your WordPress Site
Install the plugin on your website, let it sync and you’re done. Get automated, scheduled backups for your critical site data, and make sure your website never experiences downtime again.