4 Ways to Increase PHP Memory Limit in WordPress

Well we’ve all seen this common error when using WordPress:

PHP Fatal error: Allowed memory size of xxxx

This means that PHP has exhausted the maximum memory limit.  PHP scripts are only allocated a certain amount of memory that it uses.  In this tutorial we’ll show you 4 ways to increase PHP memory limit.

As some of PHP Hosting service providers limit PHP memory at system level, below method might not work if the value you need exceeds theirs. So before doing so, please contact your web host to verify the highest PHP memory available.

Increase PHP Memory  limit via PHP.ini file

Simply just edit your php.ini & change the memory_limit to anything you need.  Just like below:

 memory_limit = 32m

NOTE: Most Shared hosting servers won’t allow access to the php.ini file.

Once you’ve change this value you’ll be required to restart the web server in order for it to become active.

Changing PHP Memory Limit via install.php

This way is similarly to the above method all you need to do is to place the following code:

ini_set('memory_limit', '32M');

Inside the install.php file (inside the wp-admin folder).

Altering PHP Memory Limit via wp-config.php

For this method you won’t have to create any extra files in your directory.  Add the following code (below) to your wp-config.php file to increase your PHP Memory Limit to 64MB.

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

Modifying the .htaccess file to Increase PHP Memory Limit

It may not be a good idea to change the global memory limit; you may be better off changing this only inside one folder (one app or virtual host).  To do you have to find the .htaccess in your root directory of the specified domain & input the following code:

PHP value memory_limit = 64m

Note: This method will only work if PHP is running as an Apache module.