Logo
Tips And Tricks

How to increase the PHP memory

When running a WordPress website, you may encounter memory-related issues, especially if your site experiences high traffic or if you're using resource-intensive plugins or themes. Insufficient PHP memory can lead performance issues or fatal errors:

PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 462848 bytes)

Here's a guide on how to increase PHP memory for your WordPress site using various methods, including cPanel.

1. Editing wp-config.php File

One of the simplest methods to increase PHP memory is by editing the wp-config.php file, which is located in the root directory of your WordPress installation:

  1. Access your WordPress files either via FTP or through the file manager provided by your hosting provider.
  2. Locate the wp-config.php file in the root directory.
  3. Add the following line just before the line that says /* That's all, stop editing! Happy blogging. */: define('WP_MEMORY_LIMIT', '512M');
  4. Save the changes and upload the file back to your server.

2. Using .htaccess File

If you don't have access to the wp-config.php file or prefer an alternative method, you can also increase PHP memory via the .htaccess file.

  1. Access your WordPress files as before.
  2. Locate the .htaccess file in the root directory.
  3. Add the following line at the end of the file: php_value memory_limit 512M
  4. Save the changes and upload the file back to your server.

3. Using php.ini File

Some hosting providers allow you to customize PHP settings using a php.ini file.

  1. Access your WordPress files.
  2. Locate or create a php.ini file in the root directory (if it doesn't already exist).
  3. Add the following line to increase PHP memory: memory_limit = 512M
  4. Save the changes.

4. Using cPanel

If you have cPanel access, you can also increase PHP memory through the interface.

  1. Log in to your cPanel provided by your hosting provider.
  2. Navigate to the "Software" section and click on "Select PHP Version" or "PHP Configuration," depending on your cPanel version.
  3. Locate the option for "memory_limit" or similar.
  4. Increase the memory limit value. You may have a dropdown or input field to specify the limit. Set it to your desired value (e.g., 512M).
  5. Save the changes.

Last updated on 2/28/2024, 3:11:05 PM
Was this page useful?
UiCOre PRO Wordpress Theme

Introducing UiCore PRO

Unlimited websites in a single subscription.

"This is one of the best themes I've ever used."

Anterblackbird, USA