If your WordPress site is hosted on a shared host, you might probably run into an error message saying the allowed memory size has been exhausted. This basically means that your server is out of memory. Web servers are pretty much the same as your computer - it needs memory to process the site. When it runs of memory, you end up seeing that error.
In this foundational tutorial, we will show you a simple solution to increase the PHP memory limit on your server, with a choice of 3 methods. We know that error messages can be annoying so check out this tutorial if you're also running into issues with WordPress being stuck in maintenance mode.
Before We Begin - Contact Your Hosting Provider First
You may want to contact your hosting provider before you begin because some hosts don't allow users to increase PHP memory. In some cases, only the host provider can change the PHP memory limit on the server. Ask your host provider what is the best way to change the PHP memory limit.
Method 1) Edit the wp-config.php file
With WordPress, you can change the memory limit by editing the wp-config.php file. First connect to your server with a FTP software or you can login to your cPanel and use the File Manager tool provided.
The wp-config.php should locate in the root folder where you have WordPress installed. Edit it and add the following line:
define('WP_MEMORY_LIMIT', '256M');
Method 2) Edit the php.ini file
If you have access to the php.ini file (note that some host providers don't give access to the php.ini file), you can locate the code for the memory limit and change it to 256 MB. The code would look like the image below:
memory_limit = 256M ; Maximum amount of memory a script may consume (64MB)
Method 3) Edit the .htaccess file
You can also edit the .htaccess file located in the root folder and add the following line of code to increase the PHP memory limit:
php_value memory_limit 256M
If you have tried all of the above and nothing has worked, contact your host provider about the issue. They might not allow users to change the PHP memory limit or might have a different way of doing things. But they will likely help work out the solution you need. Thanks again for reading!
If you've found this foundational WordPress tutorial helpful, be sure to take a look at our most recent one on hosting Google fonts on your own server. 'Til next time!
DNN
March 11, 2019 @ 4:07 pm
To be honest, I never thought of that. Hopefully, that does good for WordPress bloggers looking to increase their memory extension on dedicated servers and hopefully boost their search engine optimization efforts.
Meera
March 12, 2019 @ 11:07 am
I am amazed that it can be done so easily and till now I was searching for this everywhere. I would just like to thank for your efforts in tutoring us so well.
Davi
March 15, 2019 @ 5:40 am
Very helphuf, i will try to my WordPress.
I hope can successful