Web
Analytics

Expert Hoot

"How To" Tips and Tricks

How To Increase php Memory Limit In WordPress

If you are WordPress user and seeing a PHP memory limit error message on your dashboard while downloading any new plugin, upgrading your WordPress version or performing other tasks, then a solution to your problem is given below in the guide.

The message may look something like,

“Fatal Error: Allowed memory size of *** bytes exhausted(tried to allocate **** bytes) in /home4/xxx/public_html/wp-includes/plugin.php on line xxx”

WordPress is usually the best platform to run websites and blogs. It provides all the necessary resources to run the website smoothly. But in some exceptional cases, you may encounter this error. You can easily create a website and these kind of errors are not a big deal.

We usually get up a sufficient amount of memory from WordPress to install a number of plugins without any problem. But when we install large sized plugins and files to an extent, that it reaches to the maximum memory limit offered by WordPress, then such a situation occurs.

Now the question arises how to resolve such errors?? Well, don’t panic! There a number of ways to PHP set memory limit and resolve this problem.

I’ll try to cover few of them here. The problem might seem big, but the solution is very easy. Yes, it would hardly take your two minutes if you have been on your hosting account before.

But if you have never logged into your hosting account and have never tried your hands on your cPanel, it might seem little tricky to you! Well, whatever it is, we will only get to know once we will move to the guide, so are you ready??

Let’s see what are the steps involved!

How To Increase PHP Memory Limit in WordPress

Before getting on to our guide, let me inform you that it involves a bit of coding skills. If you have got that, then the guide might help you.

But in case, if you are a complete novice, then beware, things might get messy to you. In that case, the best solution for you is to contact your hosting provider and talk to them about the error.

Since you have paid them, it’s your right to get the things done right. But, if you know the little bit of coding, then I will suggest read the guide below and resolve the issue, it will take less time than contacting the customer executive and get the things done.

So let’s get started with the methods.

#Method 1. Increase Memory limit via wp-config.php

This is the best yet easiest way to resolve memory limit error. In this method, you just need to go to the wp-config.php file on your server and add a line of code there. Here’s how to do that,

  • Login to your hosting account.
  • On your cPanel, scroll all the way down to Files.
  • Now under files, click on the File Manager. You’ll be prompted with the following window.
  • Now select Web Root(public_html/www) and Show Hidden Files. Now select the domain which is having the error(In case there are multiple domains hosted on your hosting), and then click Go.
  • Now on the left side, you’ll see a long list of files in the public_html directory. There, you need to search for the file wp-config.php.
  • Once found, select the file by clicking on it and click on the code editor on the top of the screen. If you can’t find the option, a screenshot for the same is given below.
  • In wp-config.php editor file, just add the following command,

define(‘WP_MEMORY_LIMIT’, ’64M’); 

That’s it! Once you do this, memory limit on your WordPress would be increased and you no longer have to bear this error.

#Method 2. Increase Memory limit via PHP.ini file

The second method is similar to the above method. But this time, we need to tweak the php.ini file. You can increase the memory limit of your WordPress by adding the command memory_limit = 64M into the php.ini file.

But there is a problem. Not all the hosting providers allow you to access php.ini file. Some hosting providers might allow you to create a duplicate file of  php.ini and the same named file will overwrite the previous file. This way you can edit that file.

But some hosting providers don’t even allow to create the duplicate file. In that case, others methods need to be followed. So, if you don’t get php.ini file on your WordPress, go for other methods.

#Method 3. Increase Memory limit via .htaccess file

The third way to increase the memory limit is by .haccess. If you have a newly created hosting and WordPress account, probably you won’t have this file on your server.

In order to add the command to exceed the limit of your WordPress memory, you’ll have to create this file. Once done, just add the following command line into .htaccess file,

php_value memory_limit 64M  

This command will maximize the memory limit to 64MB. If you want even more memory, just replace the number 64 to 96M, 128M etc and your memory error would be resolved.

For those, who don’t know how to create a file on the hosting account, just follow the below steps

  • Open the directory, where you want to create the file.
  • Click on the New File option on the top left in the corner.
  • Write the name of the file and click on the Create New file button, the file would be created.

#Method 4. Increasing Memory limit via install.php

Now coming to the last method i.e increasing the memory via install.php file. For this, find the wp-admin folder on your server. There, you’ll see a file called install.php.

You need to open this file in the code editor and add the following command line. Once done properly, it will cause the memory increase in WordPress and the issue would be resolved. The command is,

ini_set('memory_limit','32M');

That’s it for the guide! With this, I’ll have to wrap up the article. If you own a website then you must be aware of DDoS attacks. Here is how to protect website from DDoS attacks.

Now use any of the method mentioned above and get the PHP memory limit error resolved. It’s that easy!

I hope, the guide helped you to get the things done. And in case, if you still can’t solve the issue and the problem persists, please contact your hosting provider via live chat or contact form!

And don’t forget to tell us how did you like the guide and which method you found easy? And if you know any other better way, mention in the comments section below.

Share on Pinterest

Leave a Reply

Your email address will not be published. Required fields are marked *