Shahriar Kabir

Software Engineer

MCPD

OCJP

MCSE

Shahriar Kabir

Software Engineer

MCPD

OCJP

MCSE

Blog Post

How to Increase the PHP Memory Limit in WordPress

February 18, 2022 WordPress
How to Increase the PHP Memory Limit in WordPress

PHP Memory Limit  – If you’ve updated your PHP, removed poor-quality plugins, cleaned up your content, and you’re still getting memory errors, you may need to increase the memory limit.

There are several ways to accomplish this goal:

  • Edit your wp-config.php file.
  • Edit your PHP.ini file.
  • Edit your .htaccess file.
  • Use a memory increase plugin.
  • Contact your hosting provider.

How to Increase the PHP Memory Limit in WordPress

1. Edit your wp-config.php file.

If you’re reasonably confident in your tech skills, you could try editing your wp-config.php file.

First up? Getting to it. Use a file transfer protocol (FTP) or SSH file transfer protocol (SFTP) service to connect with and access your WordPress files. Your mileage will vary depending on the solution you use, but you should see something like this:

How to Increase the PHP Memory Limit in WordPress

Open the wp-config.php file and search for this text string: define(‘WP_MEMORY_LIMIT’, ’32M’);

Then, modify it to read define(‘WP_MEMORY_LIMIT’, ‘128M’); You can go as high as 256MB, but in most cases, you won’t need this much memory.

2. Edit your PHP.ini file.

If editing your config file doesn’t solve the problem, you can also try modifying your PHP.ini file. Worth noting? Since this file governs server settings, you won’t be able to modify it if you’re using a shared hosting provider.

Look for the line memory_limit = 32M and again change it to read 128M. It’s also a good idea to modify the max_execution_time line. This line specifies the amount of time in seconds allotted for a PHP script to run. If the time limit is exceeded, PHP returns an error. Increasing this number gives your scripts more time to run, which is a good idea if you’re planning to use more memory-intensive services and plugins.

3. Edit your .htaccess file.

Your last file editing resort is the .htaccess file. While it is accessible via the directory and file list returned by FTP connections, the “.” in front means that it’s a hidden file. If you don’t see it, check to make sure your FTP or SFTP solution is set to display all hidden files and directories.

Once you’ve accessed the file, find this line: php_value memory_limit Then, add the value you want — 64M, 128M, or 256M — and save the file.

Regardless of the file editing method you choose, make sure to clear your cache before checking to see if the problem is resolved.

4. Use a memory increase plugin.

Another option to increase your available PHP memory is through the use of a plugin, such as the WordPress WP Memory Limit, Memory Usage, Server Memory, and Health plugin. This plugin works with WordPress version 5.2 or higher and lets you modify available PHP memory without the need to access or modify files.

5. Contact Your Hosting Provider

Last but not least? Contact your hosting provider and ask them to increase your WordPress PHP memory limit. Depending on the type of hosting you have — shared, dedicated, or virtual private server — this may be a quick fix or it may not be a service offered.

PHP memory errors in WordPress are frustrating, but they aren’t permanent. By modifying your WordPress files, using a plugin, or contacting your hosting provider, it’s possible to significantly increase your available memory and avoid PHP problems.

Related posts:

Write a comment