Logo
Bearhost Logo

How to Increase PHP Memory Limit in cPanel

By Elliot, BearHost·

PHP memory limit errors occur when a script tries to use more memory than allowed. Common error messages include "Allowed memory size exhausted" or "Fatal error: Out of memory." Increasing the limit resolves these issues.

When You Need More Memory

  • Installing or updating large plugins or themes
  • Importing large amounts of content (WooCommerce products, blog posts)
  • Running resource-intensive plugins (page builders, image optimisation)
  • Processing large uploads or bulk operations
  • Seeing "Allowed memory size of X bytes exhausted" errors

Check Your Current PHP Memory Limit

Via WordPress Site Health

  1. Go to Tools > Site Health > Info
  2. Expand Server
  3. Look for PHP memory limit

Via phpinfo

  1. Create a file called info.php in your web root with: <?php phpinfo(); ?>
  2. Visit yourdomain.com/info.php
  3. Search for memory_limit
  4. Delete info.php immediately after (it exposes sensitive server info)

Method 1: MultiPHP INI Editor (Recommended)

This is the easiest and most reliable method in cPanel.

  1. Log in to cPanel
  2. Go to Software > MultiPHP INI Editor
  3. Select the Basic Mode tab
  4. Choose your domain from the dropdown
  5. Find memory_limit in the list
  6. Change the value to 256M (or 512M for large sites)
  7. Click Apply

Changes take effect immediately — no server restart needed.

Method 2: .htaccess File

  1. In cPanel File Manager, navigate to your web root (public_html)
  2. Enable Show Hidden Files in Settings
  3. Open .htaccess and add at the top:
php_value memory_limit 256M

This method works on Apache servers. If you get a 500 error, your server may use LiteSpeed with different syntax — use Method 1 instead.

Method 3: .user.ini or php.ini

Create or edit .user.ini in your public_html directory:

memory_limit = 256M

This works on both Apache and LiteSpeed servers. Changes may take up to 5 minutes to apply.

Method 4: wp-config.php (WordPress Only)

Edit wp-config.php and add before the line that says "stop editing":

define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
  • WP_MEMORY_LIMIT sets the limit for front-end operations
  • WP_MAX_MEMORY_LIMIT sets the limit for admin/back-end operations

Verify the Change

After making changes, verify the new limit using the same methods described above (Site Health or phpinfo). The new value should be reflected immediately or within a few minutes.

Recommended Values

| Site Type | Recommended Limit | |---|---| | Simple blog | 128M | | Business site with plugins | 256M | | WooCommerce store | 256M–512M | | Large multisite or membership site | 512M |

Troubleshooting

  • 500 Internal Server Error after change: The method you used is not compatible with your server. Revert the change and try a different method.
  • Value does not change: Clear any caching (server and browser), wait 5 minutes, and check again. The .user.ini method can have a delay.
  • Host limit: On shared hosting, there may be a maximum enforced by the server. On BearHost shared plans, the maximum is typically 512M. Contact support if you need more.
  • Still getting errors: The issue may not be memory. Check your error logs in cPanel > Metrics > Errors for more specific information.
Tags:#cpanel#php#memory-limit#performance#wordpress#troubleshooting