How to Increase PHP Memory Limit in WordPress
WordPress is light and consumes very little memory by default. But now WordPress became very dynamic, in my sense nothing is impossible with WordPress, I reviewed some of high functionality sites using WordPress, like Payoneer, Upwork, Facebook using some other their pages. So default memory consumption pattern is not enough, even to make small website in WordPress. We have to increase PHP limit in order to avoid Memory Size Exhausted Error. Like this one:
Fatal error: Allowed memory size of xxxxx bytes exhausted (tried to allocate xxxxxx bytes) in /home/xxxxx/public_html/wp-includes/plugin.php on line xxxx
This error shows when your host’s PHP Memory limit is less than required to perform its functionalities.
In that case, we have to increase PHP memory limit. There are few methods to increase PHP memory limits, let’s see:
Increase Memory Limit with php.ini File
Very common and easy method is to update memory limit using php.ini file. I also love to use this method. Login to your cPanel or connect with FTP, then move to file manager, then move to where your WordPress installed, then move to wp-admin folder, create a php.ini file on wp-admin folder and add this following code:
memory_limit = 64M
This will increase memory limit to 64 MB.
Increase Memory Limit with wp-config.php File:
WordPress configuration file will help us to increase memory limit on this process. Please login to your cPanel or connect with FTP, then file manager, your WordPress installed directory, then add following code to wp-config.php just above /* that’s all, stop editing! Happy blogging. */ this text:
define (‘wp_memory_limit’, ‘64M’)
Increase Memory Limit with .htaccess File:
Best option it php.ini if not works or you don’t like that process, let’s learn how increase maximum file upload size in WordPress using .htaccess
Login to cPanel or connect with FTP, go to root folder and find .htaccess file, click edit and add these codes at the bottom.
php_value memory_limit 64M
You are not getting .htaccess file? Look carefully there is a settings button on the right top, click on settings, then select Show Hidden Files (dotfiles) and click on save. Then try to find. If not found, please create one.
My Recommendation: Personally I like to upload php.ini file on wp-admin. For some cases (maximum on shared hosting), this will not work, please try others too. If not works please contact with your hosting provider. I got some hosting they turn off these. Feel free to ask me more!