Increase PHP Memory Limit in WordPress

July 24, 2018

By default, WordPress has a limit for uploading images, videos, and other files. It’s a similar thing for PHP memory limit, which helps you run plugins and scripts.
If you run a website full of content, as soon as those limits are reached, probably you’ll have problem with display of page. You may receive an error that looks similar to this one:

This is one of the most common WordPress errors, and you can easily fix. In this article, we will try to explain how to fix WordPress memory exhausted error and will found out why it happens.

 

What is WordPress Memory Exhausted Error?

WordPress is written in PHP server-side programming language.

Every website needs a WordPress hosting server for it to function properly. WordPress running on a server is like any other program running on computer: it requires a certain amount of memory to run. As harder WordPress is working, as more memory it uses.
WordPress has a default memory allocation rule in place to prevent big usage of server memory by applications.speedupThis is a useful measure to prevent a broken script from using up all available server memory and crashing the server.
However, WordPress’s memory limit defaults to value: 64MB, but often it’s not high enough and we have issues with a website work.

One way to avoid memory exhausted error — increase PHP memory limit in WordPress.

 

  • Increase PHP Memory Limit in WordPress Amending Your wp-config.php File

First, try to edit the wp-config.php file on your WordPress site. It is located in your WordPress site’s root folder.
Edit this file, for example with the command:
sudo nano /var/www/html/wp-config.php
Next, you need to paste this code in wp-config.php file just before the line that says ‘That’s all, stop editing! Happy blogging.’
Define(‘WP_MEMORY_LIMIT’, ‘256M’);

code for increase mamory in wordpress article

This code tells WordPress to increase the PHP memory limit to 256MB.
You can customize the number to increase the memory limit to a higher amount if you wish. Then you need to save changes and upload your wp-config.php file back to your server.
You can visit your WordPress site and memory exhausted error should disappear now.
If the error is still occurring, you may need to increase the WordPress memory limit to a higher number.

 

  • Updating Your php.ini File

If you use cPanel, move to the Files and click on the File Manager button. Make sure the checkbox for Show Hidden Files is checked and then press Go.
Select your wp-admin folder and find a file php.ini or php5.ini. If you can’t find it, create one by clicking the New File button in the top left-hand corner. Name the file php.ini and click Create File button on the pop-up.
If you made everything right, but it still doesn’t work, try to rename the file to php5.ini. Open the file, add or edit the following lines. After it press save and close.

upload_max_file_size = 100M
post_max_size = 200M
memory_limit = 300M
file_uploads = On
max_execution_time = 180

Change the 100M, 200M and 300M limit to the value you require.
Changing the value of max_execution_time will limit the amount of time spent loading a script in seconds.
Generally, the values you enter should increase from top to bottom 100-200-300.
The upload_max_filesize value should be the smallest, post_max_size is medial and memory_limit should be the largest.
Before to check the result, clear your browser’s cache.

 

  • Editing Your .htaccess File

If aditing of php.ini file doesn’t work, try to edit .htaccess file and add/edit the following code at the bottom:

php_value upload_max_filesize 100M
php_value post_max_size 200M
php_value memory_limit 300M
php_value max_execution_time 180
php_value max_input_time 180

Code changes are similar to your php.ini file. Put the limits value you require. Save when you’re done and clear the cache for your browser.

 

  • Contact Your Host

If all advises does not work, it means your web hosting service provider does not allow WordPress to increase PHP memory limit. You have to contact web hosting provider and ask to increase your PHP memory limit manually.

Hopefully with a help of this article you will solve WordPress memory exhausted error and increase PHP memory limit without any problem.

 

 

Leave a Reply

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

Buy Now Bundle and save over 60%

Buy now