Loading...

Knowledge Base
 Up to 70% off  on  WordPress  hosting for WordPress Websites and Stores!

How To Increase the PHP Memory Limit

Are you struggling with memory-related errors in your PHP application? Would you like to boost its performance and ensure seamless functionality? If yes, then increasing the PHP memory limit is the solution you need! Our step-by-step guide will help you learn how to increase the PHP memory limit on your server to enjoy faster, smoother, and error-free application performance.

The PHP memory limit is a setting that determines the maximum amount of memory a PHP script can consume during its execution. If a script exceeds this limit, it will result in a fatal error, and the script will stop running. It's an important setting to consider when working with large applications or handling a large amount of data. The default memory limit is usually set to 256MB. Still, depending on the application's needs, it can be increased or decreased.

Tip:

  • It's always a good practice to take a backup of any file before making any changes to your server. If anything goes wrong, you can always restore the original file and start over.
  • The default PHP Memory Limit on your server is 256MB. The universal recommended baseline is 128MB, which should be more than enough for most sites unless you have a plugin or theme that needs more. You can always customize this value inside your cPanel, depending on your needs.

There are several ways how to increase the PHP memory limit. Here are a few:

How to Increase the PHP Memory Limit via php.ini

If you want to know how to increase the PHP memory limit of your PHP script, editing the php.ini file is the most common way to do it. The php.ini file contains several directives that are used to configure the PHP settings. One of these directives is the memory_limit directive, which sets the maximum amount of memory that a PHP script can use. The memory limit is set to 256 megabytes (MB) by default. However, more than this may be needed for some scripts, especially those that deal with large amounts of data. You may need to increase the memory limit to avoid any memory-related errors.

Using the MultiPHP INI Editor

  1. Log in to your Bluehost Account Manager.
  2. Click the Hosting tab from the side navigation menu to the left.
    Bluehost Dashboard highlighting 'Hosting' tab
  3. Scroll down to click the CPANEL button under Quick Links.
    Bluehost Dashboard highlighting 'CPANEL' button under Quick Links
  4. Under the Software section, click on the MultiPHP INI Editor icon.
  5. Select the domains that you want to set up or update from the Select a location drop-down
  6. Set your desired values for memory_limit (increase/decrease) on the right-hand side.
  7. Click the Apply button to finish the update.

Using the File Manager

  1. In the cPanel, locate the Files section and click the File Manager icon.
  2. If prompted, choose Web Root; otherwise, navigate to the public_html folder.
  3. Locate the php.ini file, then click and highlight the file.
    cP Edit icon
    Alternatively, highlight the php.ini file and right-click your mouse to show a drop-down menu. Click Edit, and then the same popup window will appear.
  4. Click the Edit button.
    cP Edit Dropdown option
  5. Click the Edit button on the popup window to open the code editor.
    cP Edit popup Edit button
  6. Search for memory_limit without the quotes.
  7. Enter the new memory limit for your PHP applications.
  8. Once you finish editing memory_limit, click Save Changes before closing the editor.

Using an FTP Client

  1. Connect to the server with your FTP client.

    To learn more, please see Introduction to FTP

  2. Navigate to the public_html folder.
  3. Download the php.ini file.
  4. Open the file with any text editor.
  5. Search for memory_limit without the quotes.
  6. Enter the new memory limit for your PHP applications.
  7. Save the file.
  8. Upload the file using your FTP client.

How to Increase the PHP Memory Limit via .htaccess File

If you don't have access to the php.ini file, you can edit the .htaccess file. Add the following line to the file: php_value memory_limit 256M. This will set the memory limit to 256 MB. Save the file and check if the new limit has been applied.

  1. In the File Manager, look for the Settings button located towards the upper right corner of your screen.
  2. From here, click the Preferences popup, then click the checkbox for Show Hidden Files (dotfiles).
    Preferences window with options to show hidden files and set web root directory for 'example.com'
  3. Scroll to locate the .htaccess file from the list.
  4. Right-click on the file, then click on Edit from the menu.
    .htaccess file option, selecting Edit
  5. A dialogue box may ask you about encoding; click the Edit button to continue. The editor will open in a new window.
  6. Add the following line to the file: php_value memory_limit 256M. This will set the memory limit to 256 MB. Save the file and check if the new limit has been applied.
  7. Click the Save Changes button.

How to Increase the PHP Memory Limit via wp-config.php File

  1. Inside the File Manager, look at and highlight the wp-config.php file.
    cP Edit icon
    Alternatively, highlight the php.ini file and right-click your mouse to show a drop-down menu. Click Edit, and then the same popup window will appear.
  2. Click the Edit button.
    cP Edit Dropdown option
  3. Click the Edit button on the popup window to open the code editor.
    cP Edit popup Edit button
  4. Add the following line to the wp-config.php file: define('WP_MEMORY_LIMIT', '256M');. This will set the memory limit to 256 MB.
  5. Click the Save Changes button.

How to Increase the PHP Memory Limit via Plugin (WordPress Dashboard)

There are several plugins available that can help you how to increase the PHP memory limit without the need to edit any files. These plugins can be easily installed and configured to help improve the performance of your website, such as the WordPress WP Memory Limit, Memory Usage, Server Memory, and Health plugins. It's important to note that increasing the PHP memory limit should be done cautiously and with consideration to the resources available on your server.

  1. Login to your WordPress dashboard.
  2. Go to the Plugins section and click on Add New.
  3. Search for the plugin you want to use and install it.
  4. After activating the plugin, go to Tools and click on WP Memory Usage.
  5. You will see the current memory usage of your WordPress site. Scroll down, and you will find the Memory Limit option.
    Increase the memory limit by entering the desired value in the box provided.
  6. Click on Save Changes, and you're done.

Summary

Increasing the PHP memory limit is crucial in ensuring seamless functionality and performance of your PHP applications. With the step-by-step guide, you now have several methods to increase the PHP memory limit. Whether you choose to edit the php.ini file, .htaccess file, wp-config.php file, or use a plugin, it is essential to ensure that you do it cautiously and with consideration to the resources available on your server. Following these steps will help you avoid memory-related errors and enjoy faster, smoother, and error-free application performance.

If you need further assistance, feel free to contact us via Chat or Phone:

  • Chat Support - While on our website, you should see a CHAT bubble in the bottom right-hand corner of the page. Click anywhere on the bubble to begin a chat session.
  • Phone Support -
    • US: 888-401-4678
    • International: +1 801-765-9400

You may also refer to our Knowledge Base articles to help answer common questions and guide you through various setup, configuration, and troubleshooting steps.

Did you find this article helpful?

 
* Your feedback is too short

Loading...