Increase PHP Time Limit – 3 Methods

increase PHP Time Limit

Execution Time Limit error in WordPress is one of the most common errors in any WordPress site. Probably faced when your site spending time on single operation and result, it gets time out.

Like this:

Fatal error: Maximum execution time of xx seconds exceeded...

To fix this, you need to increase PHP time limit in your WordPress site.

So in this article, I’ll help you to fix the Execution Time Limit error.

Increase PHP Time Limit: 3 Methods

Before we get into methods of increasing the time limit, let’s talk a bit about precaution measures when doing big changes to your website. Anytime you want to change something, add in new things, or update your website, it’s good to have a safety net, which brings us to WP Reset.

WP Reset

WP Reset is an excellent tool that every website owner should have in their arsenal. It doesn’t only give you something to fall back on, but it also helps prevent any errors or mistakes from happening. So, it’s your no. 1 tool for developing, debugging, and maintaining your WordPress site.

Moreover, WP Reset allows you to go back in time with just one click, which can be incredibly useful when you encounter a mistake after updating your website or plugins. Talking about plugins, you will be pleased to hear you can create collections with your favorite plugins and set them up without much hassle. With WP Reset, all you have to do is click one time, and bam, your plugin is installed.

In addition, WP Reset has its own recovery tool that will help you solve errors such as the white screen of death or nonexistent admin panel. You can even clean up your whole website with WP Reset’s cleaning tools. Plus, the Nuclear Reset option allows you to completely wipe everything.

Finally, and most importantly, WP Reset provides you with snapshots, images you take before making any major changes to your website. If you come to realize you made a mistake, you can easily access one of the snapshots and revert back to that time when everything was running smoothly.

WP Reset snapshots option

Now, the 3 methods to increase the time limit:

  • Using wp-config.php
  • Through .htaccess
  • And php.ini

But before increasing it, you should check out what’s your actual Execution Time Limit.

Note: Make sure you have a complete site backup or selected file that we gonna edit just in case something goes wrong.

How to Check the WP Time limit?

The best way to check the PHP time limit is to create a PHP file on your server like php-info.php (you can name anything) and put the following code in it.

<?php phpinfo(); ?> 

Once you put the code, upload it on your server’s public_html directory. You can access it using FTP client software or File Manager in your cPanel.

Now open this file in your browser, to open it write down your domain and file name like this domain.com/php-info.php. There you will see a table list containing all configuration info about your current PHP environment (including PHP time limit).

In case, you weren’t able to see it there. You can even check-in system status page that comes in the theme like Avada, Newspaper, Jannah.

check php time limit
Checking PHP time limit

Or you can install Server IP & Memory Usage Display to know the current time limit and view the current execution time and the PHP version you are using in the dashboard and admin footer.


Once you know your time limit stats, you can now decide how much time limit your site needed and that’s the whole point to check the limit of your site.

1. How to Increase PHP time limit using wp-config.php

This the most likable method people like to use. To do this, you need to edit the wp-config.php file on your WordPress site as it located in your WordPress site’s root folder.

Once you open this file in a text editor, paste below code in the wp-config.php file just before the line says ‘That’s all, stop editing! Happy blogging.’

set_time_limit(300);

Next, save your changes and upload the wp-config.php file back to your server. And this code tells the server to increase the PHP time limit to 300.

increase php time limit wp-config

Now, refresh your site to see if the error is gone.

If the error keeps coming, try to allocate more time limits.


2. How to Increase PHP time limit using .htaccess

If you’re not comfortable with wp-config.php, no worry you can do this via .htaccess too.

Your .htaccess file starts with a dot because it is a hidden file. So if you don’t see it in your root folder, make sure that your file manager isn’t keeping those files hidden from view.

Check show hidden files

Once you found it, open the file in a text editor and add below code to your .htaccess file:

max_execution 300

Next, save your changes and upload it to your root directory. Refresh your site to see if the error is gone. If this doesn’t work, then you need to contact server administrators.

Read more:


3. How to Increase PHP time limit using php.ini

Php.ini is one of the essential configuration files in PHP. It is used to control variables such as memory size, max upload size, max time for execution, upload directory, display errors, log errors,  etc.

To increase the time limit, you need to find this file in your server. You’ll most likely find it in the root folder, but the location of the file will vary by host.

There is one simple way to find out exactly where the php.ini configuration file located. As I mentioned earlier how to check the time limit. Same as that you need to create a PHP file and add the following code in it.

 
<?php phpinfo(); ?>

And you can able to check php.ini file location just by opening this PHP file in your browser.

Where is php.ini file
php.ini file location

Once you find php.ini or php5.ini file, open it in a text editor and paste the following code in it to increase execution time:

max_execution_time = 300;

Next, save your changes and upload them back to your server.

php ini info

Or in case if you aren’t able to find. Just Create one as php.ini by any text editor, paste exact code max_execution_time = 300; and upload it in your root directory.

You’re still having a problem?

If these solutions don’t work for you, then this means your web hosting service provider does not allow WordPress to increase PHP time limit.

You will need to ask your web hosting provider to increase your PHP time limit manually.

Sometimes your hosting limits time execution especially shared hosts. Even, many shared hosting providers don’t even give you access to your php.ini file.

In these cases, it may be time to upgrade your hosting setup to WordPress hostings.

Thanks for Reading

Enjoyed this post? Share it with your networks.

Comments (6)

  1. Branndon
  2. sanjay
  3. Anooj P
  4. shubham P.
  5. Carlos
  6. Your comment is awaiting moderation.

Leave a Feedback!

This site uses Akismet to reduce spam. Learn how your comment data is processed.