5 Ways to Increase the PHP Memory Limit in WordPress

Published On :

In case you are a blogger & you use WordPress; on some hosts you’ll notice a ‘Fatal Error : Memory Size Exhausted’ when you install a lot of plugins, upgrade to the latest WordPress version or even you’ll find an error in your Dashboard widget which prevents them from loading fully.

In case you want to reduce your plugins, then you can take a look at the Top 10 WordPress Plugins I use on DailyBlogging.

Such types of problems arise because the PHP Memory Limit of your Host is pretty less than what the process requires for performing it’s functions. In such a case you would need to follow these 5 tips to Increase your host’s PHP Memory Limit.

WordPress_Increase_PHP_Memory_Limit

Above is an image of the Error I got when I upgraded from WordPress 3.0.3 –> WordPress 3.0.4. You’ll find that there is some problem with class-http.php on line 1408.

It’s not necessary that you’ll also get the same error. But as far as WordPress Upgrades are concerned; you’ll experience a similar error on your Dashboard too.

1. Increase the limit via PHP.ini file

You can directly increase the PHP Memory Limit if you’ve access to the PHP.ini file. Most small Shared hosting servers won’t give you access to the PHP.ini file. But some servers allow you to create a duplicate PHP.ini in your respective site Directories whose data/values will override the default PHP.ini values.

To do that you just need to create a file with the name ‘php.ini’ in the directory where your WordPress site is installed. In that just add the command memory_limit = 64M in it to increase the Memory Limit to 64 MB.

2. Changing the Memory Limit via wp-config.php

If you don’t want to mess with the PHP.ini file, then you can go for this method. In this you won’t be needing to create any extra file in your Directory.

Just Adding define('WP_MEMORY_LIMIT', '64M'); in your ‘wp-config.php’ file would increase your PHP Memory Limit to 64 MB.

3. Modifying the .htaccess file to Increase the Memory Limit

A Default WordPress Installation won’t have a .htaccess file. But in case you already have it for some purposes like ‘301 Redirection’ which is an important aspect of WordPress SEO.

In such a case just add the command php_value memory_limit 64M in your ‘.htaccess’ file and your memory limit will increase to 64 MB.

4. Changing the Memory Limit via install.php

This method is just an Alternate to the php.ini method. Because the function of the code we use in this method is same as what we put in the php.ini file.

You just need to place the code ini_set('memory_limit','32M'); in the ‘install.php’ file which is placed in the wp-admin folder of your WordPress installation.

5. Have a talk with your Host

If you are a person who is new to all these techie sounding things then it’s better to have a Live Chat / a Call with your Host right away. It’s your right to talk to them & get the necessary changes you need as you’ve paid for it.

I would recommend you use some quality WordPress hosts available – viz HostGator / DreamHost / BlueHost.

Note:-

Follow any one of the above 5 Methods. Don’t try to implement all the 5 methods at the same moment, else you’ll end messing up things. If you are seriously not a coder then do consult your Host as mentioned in the 5th Point. Don’t experiment with a live blog which is getting considerable traffic.

Have you faced such Fatal Errors in your Initial Blogging Career ??

Share :
Tagged as : 35 Comments
About » Has written 231 Post(s) «

I'm a Web Designer/Developer, SEO'er and a Blogger who gives a few Blogging Tips in the form of posts/tutorials. Follow & Subscribe to my Blog if you feel it's worth it.

HostGator
Loader

27 Comments Comments RSS

  1. #

    Very thoughtful article. It will help many new bloggers. I faced this problem when I started my blog. I increased my memory via PHP.ini file.

  2. #

    Atleast we have choices thanks anyway

  3. #

    Thanks for sharing this tutorial. I always wanted to know more on this! I’d faced this when I started to blog!

  4. #

    Good tips. I think WordPress might run into memory limit problem especially if you have installed and activated many plugins.

  5. #

    I have a website that I’d to be able to grab and display the last post from a specific category in WordPress. I have WordPress hard-installed on my site (I store the information on my server.)Is there a way to do that using PHP? It sounds like it’d be simple, but I can’t find decent documentation for it anywhere.

    • #

      that doesn’t require any PHP. Just goto ur Widgets Area > Add the “RSS” Widget and put your Category Feed URL.

      For Ex : http://www.dailyblogging.org/category/internet/feed/ This will be the Category Feed for DailyBlogging’s Internet Category.

      Try it, In case you face a problem, comment here again :)

    • anu
      #

      Dear where is PHP.ini in godaddy please tell me as i want to add this code.

  6. #

    by default my memory limit was 64M so, it seems i don’t need to change it.

  7. #

    Hi Mani, increasing the memory via PHP.ini is the best way and I have done it before. Thanks for sharing the other ways to increase the PHP memory limit.

  8. #

    HostGator is the best hosting, because it provides 24/7 quality customer service.
    Thanks for these tips.

  9. #

    thanks a lot Mani for sharing this.. One of my Blog is showing the same error since 2 days back..

    • #

      Not Only Your Blog.My Blog Also Have The Same Problem ,But Now I Solved This.

  10. Very useful tips, thanks

  11. #

    Of all these I believe in php.ini configuration.. although all other are promising I prefer to use php.ini

  12. #

    all the 5 i prefer the 5 options chatting with representative. My host solves the problem within 15minutes.
    I think you consider zyma hosting too as quality webhosting provider

  13. #

    Nice article for Low Speed Server Customers , Thanks

  14. #

    you saved my life, thanks

  15. #

    Great tips. thank you. very helpful. I have a question: If I already edited the wp-config file, is it still necessary to imcrease the php memory allocation since altering the wp-config.php file only increases the memory of the wordpress installation.

  16. #

    Easiest way to solved WP 3.3, 3.3.1 slow issue

    http://wordpress.org/support/topic/wp-admin-even-33-incredibly-slow/page/2

    conclude is define(‘WP_MEMORY_LIMIT’, ’64M’); in your ‘wp-config.php’ file would increase your PHP Memory Limit to 64 MB.”

    or

    Simply add this code in WP-CONFIG.php file…

    define(‘WP_MEMORY_LIMIT’, ’512M’);

    You may change the 512M to 1024M or lower(256M/128M) but don’t use higher values like 2048M/4096M, otherwise your website stop working.

    I have own server i sert as 1024MB now it seem work fine and super fast than previous.

  17. #

    Thanks for your help

  18. gojcus
    #

    Where do you change it?. In FTP? I went to WP-CONFIG.php and I see this:

    * This file is used by the wp-config.php creation script during the
    * installation. You don’t have to use the web site, you can just copy this file
    * to “wp-config.php” and fill in the values.
    *
    * @package WordPress
    */

    // ** MySQL settings – You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define(‘DB_NAME’, ‘smartsci_wp791′);

    /** MySQL database username */
    define(‘DB_USER’, ‘smartsci_wp791′);

    /** MySQL database password */
    define(‘DB_PASSWORD’, ‘d4yPSt8s61′);

    /** MySQL hostname */
    define(‘DB_HOST’, ‘localhost’);

    /** Database Charset to use in creating database tables. */
    define(‘DB_CHARSET’, ‘utf8′);

    /** The Database Collate type. Don’t change this if in doubt. */
    define(‘DB_COLLATE’, ”);

    define(‘WP_MEMORY_LIMIT’, ’512M’);

    /**#@+
    * Authentication Unique Keys and Salts.
    *
    * Change these to different unique phrases!
    * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
    * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
    *
    * @since 2.6.0
    */
    define(‘AUTH_KEY’, ‘r2bwcu39c2ivmz6il1y8kulibxdv8zjb9fvqrsd4nwo4brs8qtruaij1vt96parz’);
    define(‘SECURE_AUTH_KEY’, ’09acuf3nwbjxekvqclqr1uui4pqakwmhc6wjmgmrsgiwz8d0dfblbnayfcczbozb’);
    define(‘LOGGED_IN_KEY’, ’5oxhczi8jr9k7ll0u3pjncklpvpuyih0wzyrytuxfsrak3rhqfvabzsbw4xdqizv’);
    define(‘NONCE_KEY’, ‘sukzcc7cfjhibmzmkivw4eoc9tyehyqkcwdsecr3cnsmvb0flnsdn5tnfxdrzcsa’);
    define(‘AUTH_SALT’, ‘krxaxblxqyc1zamzwu5lxjwnbpqpbavcluf2lewfpiw49yvsvgr2jvcqdpppqfzo’);
    define(‘SECURE_AUTH_SALT’, ‘fxu0tabiw1kin6zcjczdzgveq560qfuj3qle0mq20nyxnjsk1ts1zkelpuzcsfot’);
    define(‘LOGGED_IN_SALT’, ‘rh5ujutcctdfpgq4z9u3rwzghixay9yktjzzzd0h5u6mjbztbr7ffwq3wmof8hhf’);
    define(‘NONCE_SALT’, ‘aqfc3uh45mooys0mnlubphoohbxoc7wuovucdyhafxpsmpzlkxx6viuojltfvjyh’);

    /**#@-*/

    /**
    * WordPress Database Table prefix.
    *
    * You can have multiple installations in one database if you give each a unique
    * prefix. Only numbers, letters, and underscores please!
    */
    $table_prefix = ‘wp_’;

    /**
    * WordPress Localized Language, defaults to English.
    *
    * Change this to localize WordPress. A corresponding MO file for the chosen
    * language must be installed to wp-content/languages. For example, install
    * de_DE.mo to wp-content/languages and set WPLANG to ‘de_DE’ to enable German
    * language support.
    */
    define (‘WPLANG’, ”);

    /**
    * For developers: WordPress debugging mode.
    *
    * Change this to true to enable the display of notices during development.
    * It is strongly recommended that plugin and theme developers use WP_DEBUG
    * in their development environments.
    */
    define(‘WP_DEBUG’, false);

    /* That’s all, stop editing! Happy blogging. */

    /** Absolute path to the WordPress directory. */
    if ( !defined(‘ABSPATH’) )
    define(‘ABSPATH’, dirname(__FILE__) . ‘/’);

    /** Sets up WordPress vars and included files. */
    require_once(ABSPATH . ‘wp-settings.php’);

    where do I put the code, cos it’s not working. I tried with .htacces and the site stoped working. My limit for now is 128M

  19. #

    Just desire to say your article is as astonishing. The clarity
    in your post is just excellent and i could assume you’re an expert on this subject. Fine with your permission let me to grab your feed to keep updated with forthcoming post. Thanks a million and please keep up the rewarding work.

  20. #

    Thank you SO much… you totally saved me! I used adding the: define(‘WP_MEMORY_LIMIT’, ’64M’); to my config file and it worked like a charm! Simple and no plugin required :)

  21. joanne
    #

    Thanks so much!!!!

  22. lalit
    #

    The htacesss thing craiipled my website.
    500 error all over the site.

    i am not able to make this work, phpinfo says server memory is 128 MB but Wp limit is still set to 2 mb.

    i dont like when things dont work as they should . :(

  23. #

    This is Great

    Many Thanks for this post, I had this problem with all my sites but here I got so many different options to chose from and increase the .php Memory,
    Thanks, Viswanathan

    Regards

    D.

8 Trackbacks

  1. By Divirama | Best Dictionary Shop on January 4, 2011 at 10:23 pm
  2. By Darel Philip on January 4, 2011 at 11:36 pm
  3. By Classmild.Co.Tv on January 5, 2011 at 8:14 am
  4. By Darel Philip on January 6, 2011 at 2:05 am

Post a Comment

Your email is never published nor shared. Required fields are marked *

Also, use your Real name in the 'Name' field. Comment names with only keywords will be trashed.