How to increase PHP memory in WordPress
While using WordPress, you might face a few common issues or errors. One of the most common is the WordPress memory limit error, also known as the “PHP memory limit error”.
The PHP memory limit error is usually one of the easiest WordPress errors to fix because you know exactly what the problem is – some scripts on your site do not have access to enough memory. The solution is to simply increase your memory limit, and there are several ways to do it.
Below, we will discuss two easy methods.
Solution 1: How to increase PHP memory limit in WP_Config file
The first place to try is the wp_config.php file from your website. This file contains the basic configuration details of your website, including its PHP memory allocation. Raising your PHP memory limit from here is usually enough to resolve the issue.
You will find this file in the root folder of your WordPress site. You can access it through File Transfer Protocol (FTP) or by using cPanel.
You will need to provide the relevant details as requested on the screen. These will be:
Log in — your desired username
Password — any password of your choice
Phone book — the directory you want to access. In this case it will be your root directory, so enter ‘public_html / ‘.
Note: In most cases your web host will provide you with the default FTP details, so be sure to check with them before creating a new FTP account.
Access your root folder via FTP
If you’ve never done this before, the first thing you need to do is install an FTP client. To set one up, you will need your website’s FTP credentials. Typically, you can find these credentials in your hosting account. However, if you have any difficulties, just contact your hosting provider and they will tell you where to find them.
Alternatively, you can create your own FTP account. Log in to cPanel then navigate to File Manager> Files> FTP Accounts.
Once your FTP client is configured, you can access the files on your site. To get started, you’ll need to find your site’s root folder. For WordPress websites, this will usually be a folder called public_html. It can also be a folder with the name of the website. Once inside you will see a file named wp-config.php.
You will need to make some changes to this file, but you will need to use a little caution as any mistakes can potentially damage your website. Before going any further, back up your website for security.
After saving your site, open the wp-config.php file and find this line:
define (‘WP_MEMORY_LIMIT’, ’40M’);
The value, 40M, may be different for you depending on your hosting service. It is also possible that this line does not appear at all.
If you find it, just change the value. 256MB is generally enough memory to support just about any type of website.
If you can’t find that line, look for the line that says: âThat’s all, stop editing! Good blog. Then paste the same code just above:
Save your changes and your website should function normally.
However, if you keep getting the same error message after a few tries, it is likely that you have exceeded the maximum limit allowed by your hosting service. In this case, you will need to contact your host to request a limit.
Just like with an FTP client, you can access the wp-config.php file via cPanel. First, log in. Scroll to Files> File Manager> Public_html> wp-config.php. Once you have found it, right click and select Edit.
This will open the wp-config file in the native cPanel editor. Follow the same steps described above to change the wp-config.php file to increase your PHP memory limit.
While editing the wp-config file is usually the preferred method of increasing the PHP memory limit, there are other methods you should be aware of.
As we have demonstrated, you can increase your site’s PHP memory in cPanel’s wp-config file. There are other options in cPanel which also allow you to adjust PHP memory. One of them is the PHP selection tool.
Once in cPanel, scroll to Software > Select the PHP version> Options.
In the resulting interface, scroll down to memory_limit and select an appropriate number.
To note: This option may not be available for all hosting services.
Alternative solutions: use better web hosting
The amount of space and memory you have access to depends on your hosting provider and the hosting plan you’re paying for. Most new website owners go for cheaper shared hosting plans which can allocate little PHP memory.
While this is usually not a problem at first, you will inevitably hit the limit as your website grows and you start adding more plugins.
If you’ve followed the steps above to increase your website’s PHP memory limit and failed, there’s a good chance you’ve exceeded your hosting plan’s memory allocation.
Depending on your situation, you may need to choose another hosting plan, switch to a new hosting provider, or upgrade. Whatever the case may be, make sure you choose a reliable web host that you can rely on to give you access to high quality resources.
Access more storage space by increasing your PHP memory limit
The PHP memory limit error is one of the most common errors in WordPress. If you are using cheap hosting plans, have multiple plugins performing complex functions, or if your website is growing at a fast pace, you might run into this error sooner rather than later.
Increasing your site’s memory limit through the wp-config file is a free and easy solution, but the easiest way to prevent a PHP memory error from occurring in the first place is to use a hosting provider. reliable and a solid hosting plan. Not only will this give you better memory allocation options, but it will also give you access to other high quality resources that can improve the overall performance of your site.
Read more
About the Author
Comments are closed.