We will be going over three different methods that will allow you to increase PHP Memory Limit on your WordPress Website. Along with these three methods we will also go over two ways to access your website’s root directory and how to create a php.ini file if needed.
Let’s Get Started…
What Are The 3 Methods To Increase PHP Memory Limit?
1. Using wp-config.php file
2. Through .htaccess
3. Using php.ini file
We will be using 256M in the examples below but this can be replaced with the value you need. Example: 64M, 256M, 512M, etc.. You may be wondering why these values specify to 64M, 256M, 512M, etc.. Why can’t I just put 300M instead? The reason is you are actually putting in ram value and RAM comes in specific sizes therefore not just any size will work.
What Will I Need To Get Started?
In all 3 of these methods you will need to access your website’s root directory. There are 2 easy methods to do this.
1. Access via file manager
2. Access via FTP (File Transfer Protocol)
Note* If you need help with accessing your website’s root directory skip to How To Access Your Website’s Root Directory: 3 Methods at the bottom of this post and then come back once you have gained access.
Method 1: How to Increase PHP Memory Limit Using wp-config.php
This is the most likable method people use. To do this, you will need to edit the wp-config.php file on your WordPress site. This file is located in your WordPress website’s public_html folder.
Once you open the wp-config.php file, paste the code below just before the line that says:
/* That’s all, stop editing! Happy publishing. */
/* That’s all, stop editing! Happy Blogging. */
define( ‘WP_MEMORY_LIMIT’, ‘256M’ );
Next, save your changes.
Note* If you are using FTP once you locate the wp-config.php file right click and select view/edit. Your file will open using a text editor like notepad. Once code is entered save and then upload the wp-config.php file back to your public_html folder.
Now, refresh your site and your PHP Memory Limit should be 256M.
If you are getting errors while working in the admin area of WordPress then you’ll need to put one more line in your wp-config.php file.
Add this extra line to increase the PHP memory limit for the admin area:
define( ‘WP_MAX_MEMORY_LIMIT’, ‘256M’ );
Method 2: How to Increase PHP Memory Limit Using .htaccess
If you’re not comfortable with wp-config.php, no worries you can do this via .htaccess too.
Your .htaccess file starts with a dot because it is a hidden file. So if you don’t see it in your root folder, make sure that your file manager isn’t keeping those files hidden from view.
Once you have found your .htaccess file, open the file and add the code below. (If using FTP open the file in a text editor)
php_value memory_limit 256M
Next, save your changes (If using FTP upload it back to your root folder after saving). Refresh your site and your php memory limit should be 256M.
Note: Making a mistake while editing your .htaccess file can break your website. Please make sure you have a recent backup for your website before making any changes. If you receive an error on your website after editing your .htaccess file you need to reopen .htaccess file, remove any and all code you entered, save file and upload it back to your root folder.
Method 3: How To Increase PHP Memory Limit Using php.ini
Php.ini is one of the essential configuration files in PHP. It is used to control variables such as memory limit, max upload size, max time for execution, upload directory, display errors, log errors, etc.
To increase PHP memory limit, you need to find the php.ini file in your server. You’ll most likely find it in the root folder, but the location of the file will vary by hosting providers.
There is one simple way to find out exactly where the php.ini file is located. In your cPanel’s file manager there should be a search option. Simply type in php.ini and you should be taken directly to your php.ini file.
Once you find php.ini or php5.ini file, right click and select edit. Paste the code below to increase PHP memory limit:
memory_limit = 256M
Next, save your changes. (If using FTP save and then upload file back to your server).
Note* In some cases the php.ini file needs to be created. This can be done directly from your file manager or if you are using FTP this can be done using a text editor.
How to Manually Create a php.ini file using file manager
- Log into your cPanel account
- Open your File Manager
- Navigate to your public_html directory
- Create a new file
- Name it php.ini
- Select Create New File
How to Manually Create a php.ini file using FTP
- Open up a text editor (like notepad)
- Select Save As and name the file php.ini
- Exit text editor
- Log in using FTP
- Locate directory listing public_html
- Upload php.ini file you just created into public_html
How To Access Your Website’s Root Directory: 3 Methods
Method 1. How To Access Your Root Directory Via File Manager If You Have Managed WordPress Hosting
If you have Studio K Web Design Managed WordPress Hosting you can easily view your root directory in your file manager by going to My Products– Manage under Managed WordPress Section- Select Your Website– Tools– File Browser. You can also view your SFTP/SSH details under the Settings tab which gives you all the information you need to connect and view your root directory using FTP.
Method 2. How To Access Your Root Directory Via File Manager If You Are Using cPanel
If you are using cPanel you will need to login to your cpanel account (this can be done through your hosting provider) Once you are on your cpanel account your File Manager should be under the Files section.
Method 3. How To Access Your Website’s Root Directory Using FTP (FileZilla)
In order to connect to FileZilla, you will need to know:
|Field||What to enter…|
|Host||Your domain name or IP address|
|Username||Your FTP username|
|Password||Your FTP password|
Download, install and launch FileZilla.
Complete the following fields:
Click Quickconnect – You are now connected to your website via FTP
Note* If you are having trouble your hosting provider should be able to help you access your website’s root directory.
Still Need Help?
We are happy to help whether your our client or not. Feel free to CONTACT US with any questions you have.