How to Increase the WordPress PHP Memory Limit

>How to Increase the WordPress PHP Memory Limit
  • How to increase the WordPress PHP memory limit

Increasing your WordPress PHP memory limit can be the solution to several problems, like memory exhaustion, white screen of death, HTTP error when trying to upload images, 500 internal server error, etc.

The default memory limit for WordPress is 40MB, and you can increase it by following one of the 3 ways pointed below.

Increasing the WordPress PHP memory limit

1. Through wp-config.php

Here’s a detailed post on how to access and edit your WordPress files using 3 different methods.

This is the easiest and safest way. You just need to access your WordPress root directory and locate the wp-confing.php file.

To do that, you can use a FTP client, like SmartFTP or FileZilla, or use the File Manager from your hosting’s control panel (usually cPanel).

Here’s where you should end up:

increase wordpress php memory limit in wp-config

After you click Code Edit, you need to insert this code define('WP_MEMORY_LIMIT', '96M'); right after the first <?php, so it should look like this:

define('WP_MEMORY_LIMIT', '96M');

You could also add 64M, 256M, or something else.

This may not work if your web host won’t allow you to increase your PHP memory limit!

Here’s a video guide that we made for you:

2. Through PHP.ini

Many hosting companies don’t allow access to the PHP.ini file, so you will have to contact them. If you have access to the file, you need to add this code memory_limit = 96M (or 64M, 256M, etc.) there.

3. Through .htaccess

This can be risky because it can break the site or parts of it, usually with a 500 internal server error, so be careful.

You’ll find the .htaccess file on the WordPress root directory, where the wp-confing.php is. Or, if you have the WordPress SEO by Yoast plugin, you can go to SEO -> Edit Files -> .htaccess file, and add the code there.

This is the code you should usually add in order to increase the WordPress PHP memory limit: php_value memory_limit 96M

Add the code here:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L] </IfModule>
php_value memory_limit 96M
# END WordPress

If that code breaks the site, try this one and see if it works:

<IfModule mod_php5.c>
php_value memory_limit 96M

Here’s more about using such PHP commands in .htaccess.


Problems caused by memory limit are common, so you could increase it right now in order to prevent possible issues.

Even though there are 3 easy ways through which you can increase the WordPress PHP memory limit, the first one is the easiest and fastest method, so I recommend following that one.

I recommend backing up the files or the whole site before doing any changes!

Hope you found this post useful! Don’t forget to share it with others!

By | 2018-02-17T22:14:40+00:00 December 4th, 2014|How to|0 Comments

Leave A Comment