How to Increase php memory limit in WordPress ?


In Starting days of my blogging I was doing everything right, but sometimes WordPress still displays errors like this, and the reason behind this type of error was memory limit.

The error was something like this:

Fatal error: Allowed memory size of 12345678 bytes exhausted (tried to allocate 2345678 bytes) in /home/your-username/public_html/wp-includes/plugin.php on line 1000

I was struggling to solve this type of error and find an awesome way to fix this error. Here I’m sharing the trick to solve Fatal Error by Increasing PHP memory limit in WordPress.

By default, WordPress has a default limit for uploading images, videos, and other files. And It’s a similar story for your PHP memory limit, which helps you run plugins and scripts on your WordPress Blog/Site.

If you run a robust site full of rich content, this could be a big problem for you when those limits are reached. You may receive an upload error that something looks like this:

The uploaded file exceeds the upload_max_filesize directive in php.ini

If your PHP memory limit has been reached, you may receive a different error that looks similar to error which looks this one:


OK! So Let me Help you for FREE!!

Here we have three ways to increase PHP memory limit in WordPress.

  1. By Generating/Updating a new php.ini file
  2. Using the File Manager (Editing .htaccess file)
  3. By Editing wp-config.php file

1.  Generating/Updating a new php.ini file

Go to your cPanel and open File Manager. Now open your site directory and find the wp-admin folder. Find a file called php.ini or php5.ini in the wp-admin folder and edit it. If you don’t find it, create one by clicking the New File button. Name the file php.ini and click the Create File button. Once the file is open, add or edit the following lines and then save and close.

The M means megabytes. Change the, 1000M, 2000M and to3000M limit Changing the value with which you feel the most comfoModifythe value of max_execution_time will limit the amount of time spent loading a script in seconds.

In many cases, the values you enter should get larger as you go down the list from lines one to three. The upload_max_filesize should be the smallest while memory_limitshould be the largest. The median should be post_max_size.

Before checking to see if the error is gone, clear your browser’s cache. 

2. Using the File Manager (Editing .htaccess file)

If file trick doesn’t work, try editing your .htaccess file by editing or adding below code.

Editing this code is similar to your php.ini file.


3. By Editing wp-config.php file

Here is the easiest and simplest trick for lazy peoples who loves copy-paste. If both of above tricks won’t work then go for this trick, this will defiantly work.

Open wp-config.php file,

Copy and Paste below code as shown in Image.

Increase Memory Limit

save this file.

“Happy Bloggging!!”

Don’t forget to share this article with your friends to help them, and if you have any problem in blogging comment below I’ll try to solve your all the problems regarding blogging.