How to Increase PHP Memory Limit in WordPress – 6 Ways


increase php memory limit in wordpress

Sometimes it becomes crucial to Increase PHP Memory Limit in WordPress website. Either you want to do it to fix an error or just optimizing your website.

There may be several reasons which force you to increase PHP memory limit, such as:

  1. WP Memory Exhaust Error
  2. Internal Server Error
  3. PHP Memory requirement of the current  WordPress theme (Ex-40 MB/Request)
  4. Plugins’ PHP Memory requirement
  5. White Screen of Death 
  6. Website is running too slow 

As PHP is a server side language, you can increase PHP memory limit by accessing your website’s hosting account.

This can be done either using cPanel or FTP (File Transfer Protocol).

6 ways to increase PHP Memory Limit in WordPress

  1. Using PHP INI Editor
  2. Using PHP Options
  3. Using wp-config.php file
  4. Modifying the .htaccess file
  5. Using install.php file
  6. Talking to your web host

You can use any of the above methods, the first two methods are the easiest. The first and second method is good only if you have access to your hosting cPanel. Method 3 to 5 is applicable to both FTP and cPanel users.

Important Note: Only try one of these solutions at a time. If you cannot make one work, make sure you delete the codes/undo changes from your files before moving onto the next solution.

Let me explain all the methods one by one and step by step.

1. Via PHP INI Editor

» Login to cPanel or Login to your website host, then navigate to cPanel.

» Search for PHP INI (There is a good chance that your host provide access to PHP INI editor; if not, you should check the 2nd method)

» Click MultiPHP INI Editor

increase-php-memory-limit-in-wordpress-11» In PHP INI editor, you can alter the value of PHP option but here we have to increase the PHP memory limit only. So, just find the option “memory_limit” and increase it to either 128M or 256M (256M is recommended in order to fix various PHP related WordPress errors.)


That’s all, save changes. You have successfully done it. 

2. Via PHP Options

» Login to cPanel or login to hosting then open cPanel from there.

» Once you’re on the cPanel dashboard, search for “PHP” and click on “Select PHP Version”.

» In the next window, click on “Switch to PHP Options”.


» On the PHP Options page, navigate to memory_limit and using drop down menu, increase it to 256MB. 


» Save changes.

3. Via wp-config.php File

Using FTP

» Login to your FTP.

» Find wp-config.php file in the root directory.

» Download the file and open using Notepad++ .

» Paste this code in wp-config.php file just before the line that says ‘That’s all, stop editing! Happy blogging.’ Save the file.

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

This code tells WordPress to increase the PHP memory limit to 256 MB.

» Upload the edited file back to the root folder overwriting the present wp-config.php file.

» Save changes.

Using cPanel

» Login to cPanel and open file manager (Present under Files tab)

» Search for “wp-config.php”, single click this file and click on “Edit” to edit using inbuilt editor.


» Add this code in wp-config.php file just before the line that says ‘That’s all, stop editing! Happy blogging.’ Save the file.

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

increase-php-memory-limit-in-wordpress-6» Save changes, done!

4. Modifying the .htaccess File

Via FTP:

» Login to FTP connection, search for .htaccess file and download it.» Open it using Notepad/Notepad++. Add the following code to your .htaccess file at the end: php_value memory_limit 256M » Upload back the modified .htaccess file to root directory overwriting the original.» Save changes. 

Via cPanel:

» Make sure to have hidden files visible. Select “Only public_html” using drop-down menu and search for “.htaccess”.


» Once you find the .htaccess file, single click and edit using inbuilt editor.   » Add the following code to your .htaccess file: php_value memory_limit 256M » Save changes. 

5. Via install.php File

One more not common way to increase PHP memory limit in WordPress is using install.php file. Here’s how to do it.

Using  FTP

» Login to FTP and search for install.php file in the root directory(public_html). 

» Double click to down the file and edit using NotePad/NotePad++.

» Add the following code at the end of the install.php file


This tells WordPress to increase your site’s PHP memory limit to 256 MB.

» Once you add the code and save changes, upload the modified file back to the root directory.

Using cPanel

» Login to cPanel and navigate to File Manager

» Under file manager search for install.php file, make sure you select “Only public_html” (screenshot below).


» Once you find the .htaccess file, edit it using the inbuilt editor and add the following code at the end.


» Hit save changes.

6. Talking to Your Web Host

Tried everything but still unsuccessful in increasing the PHP memory limit? It’s time to talk to your web host.

If you’re on a shared hosting plan, you might not have access to several hosting components. In this case, you can contact your host to increase PHP Memory Limit in WordPress by 128MB/256MB (256 MB preferred). 

In most of the cases they do it, depends on your host and their customer support.

Hope this helped you increase PHP memory limit in WordPress.

Some Other Helpful Articles:

Similar Posts

Leave a Reply

Your email address will not be published.

three × 2 =