In this article, we will focus on fixing PHP memory limit issues and errors that usually occurs on our website when we install a new theme or a new plugin.

The error usually goes something like this:

PHP Memory Limit

The solution is to increase the PHP memory limit. Let us discuss the ways on how to increase our PHP memory limit.

Three ways to increase your PHP memory limit

Method 1. PHP Configuration File (php.ini)

You can adjust the PHP memory limit settings through the php.ini file which is located commonly in the root directory of your website.

Let’s use file editing tools like FileZilla to edit the php.ini file and change the allowed memory for our PHP.

  • Open the php.ini file.
  • After opening the said file, scroll down below and find the word ‘memory_limit’ and change the value from 8M to 128M or -1 (without ‘M’) for unlimited.
  • Adjust the max_execution_time, and max_input_time as well.
  • Save the file and restart your server.

Method 2. Modifying WordPress’ .htaccess file.

Alternatively, we can adjust the allowed memory settings through WordPress’ .htaccess file. However, some server restricts this method, and you may find it not working.

Let us follow the steps below to adjust the allowed memory settings through the .htaccess file.

  • Using FileZilla, login to your website and locate the .htaccess. The .htaccess file is located commonly in the root directory of your WordPress site installation.
  • After opening the .htaccess file, copy and paste the following code:
     php_value memory_limit 256M

    In the bottom of your .htaccess file just right above the “# END WordPress” comment.

  • Save and upload the newly updated .htaccess file.

Method 3. Modifying WordPress Config (wp-config.php) File.

If in case modifying .htaccess file did not work, we still have one method left. Please follow the steps below to increase the PHP allowed memory limit by modifying wp-config.php:

  • Open your wp-config.php file located in the root directory of your WordPress installation (same as .htaccess file)
  • Add the following line just below the code “define(‘DB_COLLATE’, ‘’);”
     /** Adjust the WordPress Memory Limit to 256M **/
     define('WP_MEMORY_LIMIT', ‘256M');
  • Save the file and if possible, restart your server.

That’s it! Please use the comment form below to let me know if the methods mentioned above have fixed the memory issues on your website.


2 2 Comments

  1. Awesome! Method number 1 always works as expected for issues regarding PHP memory limit. Thanks!

  2. […] issue can be fixed easily by adjusting your memory configuration. Go to this link to […]

Leave a Reply

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