How To Change PHP Time Limit WordPress? Here Are 4 Easy Ways

How To Change PHP Time Limit WordPress

Your website’s PHP time limit is a double-edged sword. On one hand, it’s a vital safety feature that prevents broken scripts from crashing your site. On the other, if it’s not set correctly, it can interrupt important tasks, like running a site backup, and cause frustrating timeout errors.

This is why knowing how to change PHP time limit in WordPress is such a useful skill. Whether you need to increase it to get past an error or simply want to ensure your settings are optimized for performance, we’ve got you covered.

We’ll walk you through the steps to adjust this setting safely and effectively.

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 backup 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 is a safety setting on your server. It decides how long any single task, like a plugin update, is allowed to run. If a task takes longer than the set time, the server stops it. This is important because it prevents a broken or slow script from using all your website’s resources and causing a site crash.

Why it matters

Finding a balanced time limit is key to a healthy website. It’s a setting that can work for you or against you.

  • When the limit is too low, important tasks can’t finish. You’ll see timeout errors when running big jobs. For example, UpdraftPlus backups are very resource-intensive, so they often need more time than the server allows. The same goes for updating a complex theme. Increasing the limit solves this by giving those tasks the time they need.
  • When the limit is too high, it weakens your site’s safety net. A shorter time limit ensures a faulty script won’t run for too long and slow down everything else. Keeping the limit reasonable protects your site’s overall performance.

Our goal is to find that sweet spot. A number high enough for your biggest tasks, but low enough to still protect your site.

We strongly recommend you make a full backup of your website now. If anything goes wrong, a backup lets you restore your site in minutes, making this whole process worry-free.

How to change PHP time limit WordPress?

We’ll guide you through four simple methods to change your PHP time limit in WordPress, giving you full control over how your site handles resource-intensive tasks:

A) Use web host settings

This is the safest and easiest way to change your PHP time limit. Most hosting providers give you a tool for this right in your control panel. We always recommend trying this first because you avoid editing any core site files directly.

The exact steps will look different depending on your host. But the process is usually very similar. We will use Cloudways as an example for this article.

☄️ Note: If you do end up editing core files, getting a site backup first is non-negotiable. You can use it to restore your site in the event of a mishap.

First, log in and navigate to your server. Start by getting into your Cloudways account and going to the server that hosts your site.

cloudways servers

Next, find the settings and packages area. Look for a section in the left panel called Settings & Packages and click on it.

Settings and packages

Now, enter the new value for the limit. You should see a field for the Execution Limit. Enter the new value you want in seconds here. We suggest starting with 300.

After you save, give it a minute to apply.

You might notice Cloudways sets this to 300 seconds by default, which is quite generous. The default time limit can vary a lot between hosting providers. This is why the error is so common on some hosting providers.

📺 Note: You might see an option to set the limit to 0. This means the script can run indefinitely. We strongly advise against using 0. It completely removes the safety feature and can let a broken script crash your site. The lowest value you can set is 1 second, but stick to a reasonable number like 300.

B) Edit the wp-config.php file

If your host does not offer an easy way to change the time limit, this is the next best method. It is a bit more hands-on, as we will be editing a core WordPress file.

But do not worry. We will walk you through it carefully. The wp-config.php file contains your site’s main configuration details, so making a small change here is very effective. Just remember that full site backup we talked about? This is exactly why we have it. A small typo in this file can take your site down.

First, you need to access your root directory. You can do this using FTP or your hosting provider’s File Manager. Your root directory is the main folder for your website, usually named public_html or www.

Next, locate and edit the wp-config.php file. Inside the root directory, you will find the wp-config.php file. Right-click on it and choose Edit. If you have to download it, use a plain text editor like Notepad or Visual Studio Code, never a word processor.

Now, add the time limit code snippet. Scroll almost to the bottom of the file. You are looking for a comment line that says, /* That's all, stop editing! Happy publishing. */. Place the following code on a new line right before that comment.set_time_limit(300);Here, 300 is the time in seconds. This is a solid, reliable value to start with.

Finally, save the file. If you are editing it directly on the server, just save your changes. If you downloaded the file, upload it back to the root directory, overwriting the old file. With the file saved, head back to your site and run the task that was causing the error again.

C) Edit the .htaccess file

If the previous methods didn’t work, let’s try editing the .htaccess file. This is a common solution, especially on shared hosting plans.

This is a powerful server configuration file, so we need to be careful. A small typo can cause a “500 Internal Server Error,” but don’t worry. It’s easily fixed by simply removing the line you added. The file is also hidden by default for safety, so our first step is to make it visible.

public_html in FTP

First, get into your site’s root directory. You can use an FTP client or your host’s File Manager. The root folder is usually named public_html or www.

Server force show hidden files

Next, force the system to show hidden files. In an FTP client like FileZilla, look for an option in the menu like Server and click Force showing hidden files. In a cPanel File Manager, you can find this in the Settings menu.

Now, find and edit the .htaccess file. Once you can see the file, open it for editing. Add the following line of code to the very bottom of the file.php_value max_execution_time 300Just like before, replace 300 with your desired time in seconds if you need a different value.

Finally, save the file and test your site. Save your changes. If you downloaded the file, upload it back to the server. Now, go back and try the task that was timing out.

If your site shows an error after saving, do not panic. It just means this method is not supported by your host. Simply edit the file again, remove the line you just added, and your site will come back online.

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.

When should you change your PHP time limit?

Knowing when to change your PHP time limit can save you a lot of headaches. The “maximum execution time exceeded” error is the most obvious sign. But several other common tasks can also hit this limit.

Here are the most common situations where you might need to adjust it.

  • Frequent timeouts during updates. This is the most common one. You will see an error when updating large plugins or themes. It is a clear sign your site needs more time for the task.
  • Importing or exporting large files. If you are moving large datasets like products, posts, or user information, these tasks can easily time out before they finish.
  • Running backups and restores. A full backup or restore operation is a big job. It needs plenty of time to complete, especially if your site has a lot of data. This is less of a problem if you use an off-site service like BlogVault, since it does the heavy work on its own servers.
  • Performing bulk actions. Any task that works on many items at once can be a problem. This includes things like compressing all your images, sending emails to a large list, or managing many users at once.
  • Handling large media files. Processing or managing a big media library takes time. A higher PHP time limit can prevent these tasks from failing midway.
  • Running database maintenance. Intensive database operations like optimization or cleaning up old data need extra time to run without errors.
  • Using custom scripts. If your site runs custom PHP scripts or cron jobs, they can sometimes take a long time to finish. A higher limit ensures they complete their work.
  • Handling complex website tasks. Your site might handle large e-commerce transactions or major content updates. These operations often need more time than the default limit offers.

Parting thoughts

Changing the PHP time limit is a key skill for managing a smooth WordPress site. While editing files like wp-config.php or .htaccess works, we always recommend starting with your host’s control panel. It’s the safest and most user-friendly approach. And if you ever get stuck, don’t hesitate to reach out to your hosting provider’s support team. They have the tools and access to solve the problem for you.

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:

You may also like


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.