How to Increase PHP Memory Limit in WordPress

Written by WordPress Expert

July 8, 2024
How to Increase PHP Memory Limit in WordPress

The PHP Memory Limit in WordPress is a crucial configuration setting that determines the maximum amount of memory a PHP script is allowed to consume on the server. This setting is essential for ensuring that WordPress and its plugins have enough resources to execute tasks efficiently without overwhelming the server. In this article, you’ll learn more about PHP memory limit, as well as how to increase PHP memory limit in WordPress.

What does PHP Memory Limit in WordPress mean


PHP Memory Limit is defined in the server’s php.ini file, and it can be adjusted based on the needs of the WordPress site. By default, many servers set a relatively low memory limit, which might not be sufficient for larger or more resource-intensive websites. The memory limit is typically specified in megabytes (MB), and common default values range from 32MB to 128MB, but for many WordPress sites, especially those with extensive plugins or complex themes, this might need to be increased.

20%

💰 EXTRA 20% OFF ALL VERPEX HOSTING PLANS FOR WORDPRESS

with the discount code

AWESOME

Grab the Discount

Why would you need to increase PHP Memory Limit in WordPress


Increasing the PHP Memory Limit in WordPress is often necessary for several reasons. Here are seven key reasons why you might need to adjust this setting:

  1. Running Resource-Intensive Plugins and Themes
  2. Handling Large Volumes of Content
  3. Improving Performance and Speed
  4. Preventing Memory Exhaustion Errors
  5. Facilitating Updates and Maintenance
  6. Enhancing Backend Operations
  7. Compatibility with Modern Hosting Environments

Running Resource-Intensive Plugins and Themes

Many WordPress plugins and themes are resource-intensive. For instance, eCommerce plugins like WooCommerce, membership sites, or complex theme frameworks often require more memory to handle their operations. These plugins and themes can generate substantial database queries, manage large amounts of data, or include advanced features that require more processing power and memory. Without sufficient memory, these plugins may fail to function correctly, leading to errors or a degraded user experience.

Handling Large Volumes of Content

Websites with a significant amount of content, such as blogs with thousands of posts, media-rich sites with numerous images and videos, or extensive product catalogs, need more memory to load and manage this content efficiently. When generating pages or executing backend processes like content updates or media uploads, the system needs adequate memory to perform these tasks smoothly. Insufficient memory can result in slow performance or out-of-memory errors, disrupting the user experience and administrative tasks.

Improving Performance and Speed

Increasing the PHP Memory Limit can enhance the overall performance and speed of a WordPress site. With more memory, the server can handle processes more efficiently, reducing the likelihood of slowdowns during peak usage times. This is particularly important for high-traffic websites where performance is critical. Faster processing can lead to improved page load times, better user experience, and potentially higher search engine rankings.

Preventing Memory Exhaustion Errors

A common issue faced by WordPress sites with low memory limits is the dreaded "memory exhausted" error. This occurs when a script exceeds the allocated memory, causing the site to crash or display a fatal error message. By increasing the memory limit, you can prevent these errors, ensuring that your site remains operational and accessible to users.

Facilitating Updates and Maintenance

WordPress updates, whether for the core software, themes, or plugins, can be memory-intensive. During the update process, WordPress often needs to extract and replace files, perform database migrations, and more. These operations require additional memory. Increasing the memory limit helps ensure that updates proceed without interruptions or failures, maintaining the site's security and functionality.

Enhancing Backend Operations

Backend tasks like importing/exporting data, running backups, or processing batch actions (such as bulk post edits or deletions) can consume significant memory. Ensuring that the PHP memory limit is adequately set helps these operations run smoothly without timing out or causing errors, thereby enhancing the efficiency of administrative tasks.

Compatibility with Modern Hosting Environments

As WordPress evolves, its requirements also increase. Modern WordPress installations, especially those using page builders, custom post types, and other advanced features, demand more memory. Additionally, contemporary web development practices and web hosting environments often expect higher resource allocations to support better performance and scalability. By increasing the PHP memory limit, you align your WordPress site with modern standards, ensuring compatibility and optimal performance.

How to Increase PHP Memory Limit in WordPress


These methods provide straightforward ways to increase the PHP memory limit in WordPress, helping to prevent errors and improve site performance. Each method involves accessing and editing different configuration files: wp-config.php, php.ini, or .htaccess, depending on your server setup and access level.

Here are three methods to increase the PHP memory limit in WordPress with detailed steps:

  1. Modify wp-config.php File
  2. Modify php.ini File
  3. Modify .htaccess File

Modify wp-config.php File

Here are the steps to increase PHP memory limit in WordPress by modifying the wp-config.php file:

  1. Access WordPress Files
  2. Edit wp-config.php
  3. Add Memory Limit Code
  4. Save and Upload

Access WordPress Files

Use an FTP client or your hosting control panel’s file manager to access your WordPress installation files.

Edit wp-config.php

Locate and open the wp-config.php file in the root directory of your WordPress installation. Before editing the wp-config.php file, create a backup copy to ensure you have a fallback plan in case things go wrong.

Add Memory Limit Code

Add the following line of code just before the line that says /* That's all, stop editing! Happy blogging. */:

define('WP_MEMORY_LIMIT', '256M');

This sets the PHP memory limit to 256MB.

Save and Upload

Save the changes to wp-config.php and upload the modified file back to the server if using FTP.

Modify php.ini File

Below are the steps to editing the php.ini file in order to increase PHP memory limit:

  1. Locate php.ini File
  2. Edit php.ini
  3. Set Memory Limit
  4. Save and Restart Server

Locate php.ini File

The php.ini file is typically found in the root directory of your server or in a folder specific to your hosting account. You might need to check your hosting documentation or contact support for its exact location.

Be sure to create a backup of your php.ini file before making any changes.

Edit php.ini

Open the php.ini file in a text editor.

Set Memory Limit

Find the memory_limit directive in the file and set it to the desired limit, such as:

memory_limit = 256M

If the directive does not exist, add it.

Save and Restart Server

Save the changes and restart your web server for the new settings to take effect. This can usually be done through your hosting control panel or by contacting your hosting provider.

Modify .htaccess File

If you wish to increase PHP memory for your WordPress site, you can also do so by editing the .htaccess file. Here are the steps to do this:

  1. Access .htaccess File
  2. Edit .htaccess
  3. Add Memory Limit Directive
  4. Save and Upload

Access .htaccess File

The .htaccess file is located in the root directory of your WordPress installation. Use an FTP client, like Filezilla or your hosting control panel’s file manager to access it. Just make sure before you add any changes, to create a duplicate .htaccess and rename it as a backup. This will be helpful in case you make any mistakes.

Edit .htaccess

Open the .htaccess file in a text editor. You can use Notepad, Sublime Text.

Add Memory Limit Directive

Add the following line of code to the file:

php_value memory_limit 256M

This sets the memory limit to 256MB.

Save and Upload

Save the changes to the .htaccess` file and upload it back to the server if using FTP.

50%

💰50% OFF YOUR FIRST MONTH WITH ALL VERPEX MANAGED HOSTING PLANS FOR WORDPRESS

with the discount code

SERVERS-SALE

SAVE NOW

In Summary


The PHP Memory Limit in WordPress is a vital configuration that impacts the efficiency and stability of a site. Properly managing and adjusting this limit can prevent errors, improve performance, and ensure a better experience for users and administrators alike.

In the case you’re unable to increase PHP memory limit in WordPress by yourself, you may want to reach out to technical support for your web host. In some cases they may be able to assist in doing this for you.

Lastly, it's important to know that while increasing the memory limit can enhance performance and stability, it’s also necessary to consider the server’s overall resources. Allocating too much memory to PHP can lead to other services being starved of resources, potentially affecting the server’s overall performance. It’s a balance that needs careful consideration based on the specific requirements and traffic levels of the WordPress site.

Need reliable PHP hosting? Check out our PHP hosting plans at Verpex for seamless performance and robust support. Our hosting solutions are designed to ensure optimal performance for your WordPress site, with resources and support tailored to meet your needs.

For those using TYPO3, a free enterprise-class CMS based on PHP, consider Verpex's TYPO3 Hosting, perfect for TYPO3 CMS websites and apps. Equipped with advanced server technology and an easy-to-use control panel, we ensure your TYPO3 projects thrive in a nurturing environment!

Frequently Asked Questions

How much memory does a site need?

512 MB of memory is needed for a small site with 500 or 1000 visits per day to work normally.

Which PHP versions does Verpex support?

Verpex supports PHP versions 7.0, 7.1, 7.2, 7.3, 7.4,8.0, 8.1 and 8.2, ensuring smooth operation for your PHP-based websites and applications. We regularly update PHP versions to maintain compatibility with the latest web standards and security patches.

Who is responsible for PHP bugs and security issues?

Any fixes will primarily be covered by the PHP developers, and regular updates are pushed out. Under a managed hosting solution, Verpex will make sure any updates are applied to your site as soon as they’re ready.

Can I use custom PHP configurations on Verpex hosting?

Definitely. We allow custom PHP configurations to match your specific requirements. Our hosting environment is flexible, allowing you to tailor PHP settings for optimal performance and compatibility with your applications.

Discount

💰 90% OFF YOUR FIRST MONTH WITH ALL VERPEX HOSTING PLANS FOR WORDPRESS

with the discount code

MOVEME

Grab the Discount
Jivo Live Chat