Increasing your WordPress PHP memory limit can be the solution to several common WordPress errors, 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.
Note that increasing your memory limit might not always take effect!
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 an 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:
After you click Code Edit, you need to insert this code define('WP_MEMORY_LIMIT', '96M');
, right before this line: /* That's all, stop editing! Happy blogging. */
You could also add 128M, 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
Back up the file before editing it.
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 -> Tools -> File Editor, 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
If that code breaks the site, remove it and try this one:
<IfModule mod_php5.c>
php_value memory_limit 96M
</IfModule>
Here’s more about using such PHP commands in .htaccess.
Conclusion
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!
Leave A Comment