Powered by Blogger.

Increase PHP memory limit in WordPress

The question – I have a WordPress blog and in wp-admin, I see an error that allowed memory size of n bytes exhausted. How do I fix this?

There is a simple solution to this problem – increase the memory limit in wp-config.php!
The file wp-config.php is located in the root directory of the wordpress installation. So if you have installed WordPress in the root HTTP directory, it is located in a path like the following:
First check if you have the memory limit set in your wp-config.php file:
grep -i MEMORY wp-config.php
This outputs nothing on my installation. So the memory limit is not set.
Add the following line to your wp-config.php file:
define('WP_MEMORY_LIMIT', '128M');
This will set the memory limit to 128 mega bytes. It’s that simple. WordPress will take it from here! There is no need to edit your php.ini file to set global defaults.
There is another variable that defines what the maximum memory limit can be:
define('WP_MAX_MEMORY_LIMIT', '256M');
If you don’t have the above variable in wp-config.php, there is no need to add this. But if it is there, you must ensure that the WP_MEMORY_LIMIT variable is set to something less than WP_MAX_MEMORY_LIMIT (or you must increase the WP_MAX_MEMORY_LIMIT).
    Blogger Comment
    Facebook Comment