How to Increase PHP Memory Limit on a WordPress Website

Home Elementor How to Increase PHP Memory Limit on a WordPress Website

If you’re a WordPress user, you may have encountered the dreaded “Allowed memory size exhausted” error. This issue typically arises when your website’s PHP memory limit is insufficient to handle the tasks required by your themes, plugins, or custom scripts. Fortunately, increasing the PHP memory limit on your WordPress site is a straightforward process. In this guide, we’ll walk you through the steps to boost your PHP memory limit, ensuring your website runs smoothly without interruptions.

What is PHP Memory Limit?

The PHP memory limit is the maximum amount of memory a script is allowed to consume on your server. By default, this limit is set to 64MB or 128MB by many hosting providers, which is often enough for most websites. However, resource-intensive themes, plugins, or customizations may require more memory. When the limit is exceeded, your site may crash or display errors, affecting both user experience and SEO performance.

Why You Might Need to Increase PHP Memory Limit

Before diving into the steps, let’s understand why you might need to increase the PHP memory limit:

  • Heavy Themes and Plugins: Modern WordPress themes and plugins come with a plethora of features, which may require more memory than the default allocation.
  • Media-Intensive Sites:  Websites with a lot of images, videos, or other media content can quickly exceed the default memory limit.
  • Custom Scripts: If you’re running custom scripts or have heavily modified your site, you may need additional memory to support these changes.
  • Large Databases: If your website has a large database with many queries running, increasing the memory limit can help improve performance.

How to Check Your Current PHP Memory Limit

Before increasing the PHP memory limit, it’s essential to check the current limit. Here’s how you can do it:

1. Using WordPress Dashboard:

  • Navigate to Tools > Site Health.
  • Click on the Info tab, then expand the Server section. Here, you’ll find the current PHP memory limit.

2. Using a PHP Info File:

  • Create a new file named phpinfo.php in your site’s root directory.
  • Add the following code to the file
  • Access the file by visiting yourwebsite.com/phpinfo.php in your browser. Search for “memory_limit” to see the current value.

Steps to Increase PHP Memory Limit

Now that you know your current PHP memory limit, it’s time to increase it. You can do this in several ways:

1. Edit the wp-config.php File

The easiest and most common method is to increase the memory limit via the wp-config.php file.

  • Connect to your website via FTP or File Manager in your hosting control panel.
  • Locate and edit the wp-config.php file in the root directory of your WordPress installation.
  • Add the following line of code just before the line that says /* That's all, stop editing! Happy blogging. */:
This line increases the memory limit to 256MB. You can adjust the value according to your needs.

2. Modify the .htaccess File

Another method is to edit the .htaccess file, which is commonly found in the root directory of your WordPress installation.
  • Access your website via FTP or File Manager.
  • Find the .htaccess file and edit it.
  • Add the following line at the end of the file:

3. Edit the php.ini File

The php.ini file controls the PHP settings for your server. If you have access to this file, you can increase the memory limit directly.

  • Connect to your website via FTP or File Manager.
  • Locate the php.ini file in the root directory or inside a folder named php.
  • If the file doesn’t exist, create a new one.
  • Add or modify the following line:

4. Contact Your Hosting Provider

If you’re uncomfortable making these changes or if the above methods don’t work, contact your hosting provider. They can increase the PHP memory limit for you, often at no extra charge.

Leave A Comment

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

image-blog