What's WP
Our everything is about WordPress - best choice of WordPress users!
How to Increase PHP Memory Limit For WordPress Websites?

How to Increase PHP Memory Limit For WordPress Websites?

Running a WordPress site or other PHP programs, you may encounter a problem like “Fatal Error: Allowed memory size of xxx bytes exhausted”, which means PHP scripts consume too much of memory, beyond the maximum memory value of your system settings. Many people are anxious when met this error, but don’t worry. Today we are going to introduce 4 useful methods to help you increase PHP memory limit with ease.

Check for PHP Memory Limit

increase PHP memory limitIn order to fix the error, you should first check whether a specific program is allocated too much memory. If you make sure all programs have no issues, you can check for your PHP memory limit.

At first, you need to create a new php file, like view-php-info.php, and then copy and paste the below code into it.

<?php phpinfo(); ?>

Upload the file to your hosting server and call it in the browser. Then, you can see the information about your PHP environment configurations, where you will see a series of PHP parameter settings and a special section about memory_limit, like the following screenshot:

php memory limit configuration

How to Increase PHP Memory Limit?

Once clear the memory_limit value, you need to increase it to meet the actual requirements. However, how much memory_limit should be set? This question depends on the needs of your site and applications. For example, the basic PHP memory_limit requirement of WordPress is 32 MB while the recommended setting is 64 MB. If you still want to install some plugins, especially those for image processing, you may increase it to 128 MB or higher.

In the below content, we introduce 4 easy methods to help you complete the process.

  1. Modify PHP.ini File
  2. It’s the easiest way to increase PHP memory limit by modifying php.ini file. However, you may don’t have the ability to access to the PHP.ini file on many shared hosting server. under this condition, you can create a new PHP.ini file in the site directories to override the default values.

    At first, create a new php file and name it as php.ini. Then, add the below command line into it to increase the memory limit to 128 MB. Alternatively, you can change the value as 64 MB or 256 MB as you need.

    memory_limit = 128M

    At last, upload this file to your directory where the WordPress site is installed.

  3. Configure wp-config.php
  4. If you don’t want to create a duplicate php.ini file, you can increase PHP memory limit by configuring wp-config.php file. Find your this file under the root directory, and then add the follow code into it. As well, you can also change the 128M as 64M or 256M as you want.

    define('WP_MEMORY_LIMIT', '128M');
  5. Change .htaccess File
  6. Before to start, please note that this method is valid only if php execute as an Apache module. Look for .htaccess file under the root directory. If you don’t find, you can create a new .htaccess file and paste the below code into it.

    php_value memory_limit 128M ; 
  7. Contact Your Hosting Company
  8. If all the 3 methods cannot solve this problem, you can try to contact your hosting provider. Some shared web hosts usually limit the maximum memory limit or completely forbid you to change it. In this case, you can contact the web host for an efficient solution. If the environment still cannot meet your requirement, you may consider transferring your site to a truly reliable web host.

    The following companies are three of the best WordPress hosting companies. They provide superior hosting service along with affordable price, rich features, 99.9% uptime, excellent speed, and professional support. Besides, they also provide reliable VPS hosting plans for customers whose websites have gone out of the shared resources.

Author

Joyce is a professional writer & SEOer who loves trying new things and sharing the experience through blogging. She loves clean design, playing with different WordPress themes, SEO, etc. Now she is very struggle with purchasing a bubbling apartment in downtown. You can help her by clicking our ADs or making a purchase via our links ;-)

Close

Want to Learn More About WordPress?

Get Our Free Themes, Plugins, Support, SEO Tips, and Other Tutorials!

Email *