How to increase the PHP Memory Limit in WordPress

How to increase the PHP Memory Limit in WordPress

To explain the PHP memory limit easily, I have to put it into a comparison: you can imagine it in the same way as your computer’s memory.

It indicates how much memory a script can use and it has absolutely nothing to do with your storage space, which is filled with your images, for example!

Since WordPress & plugins are based on PHP, this PHP Memory Limit is very important for smooth operations on your WordPress site.

When you need to increase the PHP Memory Limit

In my article on the typical WordPress problems, I have already described the increase of the PHP Memory Limit as a possible solution to the White Screen of Death and problems with image upload.

However, there are also plugins that do not work or do not work properly without a certain PHP memory limit. For example, in WooCommerce there is a status page that shows you whether all requirements are met. If the PHP memory limit is too low, it looks something like this:

PHP Memory Limit Check in WooCommerce
PHP Memory Limit Warning in WooCommerce

If a script cannot be executed and the PHP Memory Limit is to blame, then an error message like that may also occur:

Fatal error: Allowed memory size of x bytes exhausted (tried to allocate x bytes) in /pfad/pfad/php/datei

In all these cases, you need to increase your memory limit.

How to check the current PHP Memory Limit in WordPress

As you can see in the screenshot above, some plugins display the PHP memory limit.

WordPress itself also has a function for this, under Tools -> “Site Health” -> “Info” -> “Server”.

So prüfest du in WordPress das PHP Memory Limit
Check the PHP Memory Limit in WordPress under “Tools” -> “Site Health”

How to increase the PHP Memory Limit

There are several files in which you can enter the code you need to increase the limit:

  • wp-config.php (my recommendation)
  • .htaccess
  • php.ini
  • contact your hoster

All three files are located in the main directory of your WordPress installation, which you can access via FTP.

[Recommendation] Increase PHP Memory Limit with the wp-config.php file

I recommend you to adjust the PHP Memory Limit via the wp-config.php file!

You can find the wp-config.php file in the main directory of your WordPress installation.

So log on to your server with your FTP Client and open the wp-config.php.

Scroll down a bit to the part of the code where it says:

/* That’s all, stop editing! Happy blogging. */

You now add the following code to this:

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

Increase PHP Memory Limit with the .htaccess file

The .htaccess is a powerful file and you can do a lot of damage with it,so you have to be careful what you do!

You can find this file in the main directory of your WordPress installation. However, it is a “hidden” file, which is symbolized by the dot in front of the name. You must allow hidden files to be displayed in your FTP program, otherwise you won’t be able to see them.

Enter the following code at the end of the file:

php_value memory_limit 256M

Increase PHP Memory Limit with php.ini

With the php.ini file you can make settings on your server. Among other things, you can also increase the PHP memory limit here.

Just like with the .htaccess, you can break your website with this file, so be careful! Not every hoster provides you with a php.ini file (one of the reasons why I recommend setting via wp-config.php).

If you perform the increase via the php.ini, insert the following code:

memory_limit = 256M;

Contact your hoster

Of course, you can also contact your hosters’ support. The good hosts will help you with the increase of the PHP Memory Limit!

Just ask the support staff to increase the PHP memory limit for your website.

0/5 (0 Reviews)

Leave a Reply

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