How-To Change PHP memory limit for WordPress

If you have been working with WordPress chances are you have received the error stating that “Fatal Error: Allowed memory size of xxx bytes exhausted (tried to allocate xxxx bytes) in some-file.php on line xxxx” while upgrading you WordPress version, or a plugin or even just trying to upload some files.

The reason is that while executing PHP.ini file  it exceeds allowed PHP memory on the server. Generally this happens if the value for memory_limit is set to low (probably 8M etc.) in PHP configuration file php.ini. There are some workaround to increase the value for PHP memory. But if you are using BlueHost or Hostmonster, here is the way to solve this efficiently.

changing memory limits on php.ini file

Please follow these simple 11 steps:

Step 1- Login into your cPanel. (Usually www.yourdomainname.ext/cpanel)

Step 2- Under the Software/Services category, click on the PHP Config icon.

Step 3- In this screen, there is a section called “Install Default php.ini”. Under that section, please check mark the “IonCube” and the “SourceGuardian” check boxes (Many commercial php scripts need these turned on – if you think your script may not require the IonCube or SourceGuardian packages, it is okay to not check mark the boxes – but it will not hurt anything to check mark both boxes.).

Step 4- Under the same section, click the “INSTALL PHP.INI MASTER FILE” button.

Step 5- You have just successfully installed the “php.ini.default” file . But the next step is to rename it from “php.ini.default” to just “php.ini” to make it active. You can do the Rename in the File Manager screens. Under the Files category in your cPanel, please click on the File Manager icon.

Step 6- When you click on the File Manager icon, you should get a popup dialog titled “File Manager Directory Selection”. (If you do not see the popup dialog, then you need to click on the link at the bottom of your cPanel called “reset all interface settings” – and then Refresh your cPanel and click on the File Manager icon again.) In the popup dialog screen, click the “Web Root (public_html/www)” and the “Show Hidden Files (dotfiles).” choices. Finally please click the “Go” button.

Step 7- If you already have a “php.ini“, I would recommend that you Rename the file to “php.iniOld” in case you ever need it.

Step 8- Find the file that you just installed called “php.ini.default“, Right-Click the file and choose the Rename option.

Step 9- A new popup dialog called Rename should appear. Please start pressing your Backspace on your keyboard until you see only “php.ini”, and then click the Rename File button.

Step 10- Your php.ini file is now active and fully functional !! Now its time to make adjustments to this file. To edit the file, you just Righ-Click the php.ini file and choose the Edit option, and then change the value like these examples show:

a. To increase your memory for your php pages: memory_limit = 2M —> memory_limit = 100M or

b. To turn on your Register Globals: register_globals = Off —> register_globals = On (I don’t recommend that you change this flag unless you know what you are doing.)

or

c. To increase the maximum file size for uploading (there are two flags that you have to change):

post_max_size = 2M —> post_max_size = 100M

upload_max_filesize = 2M —> upload_max_filesize = 100M

d. To turn on PDO, add these lines of code to your php.ini file (only if  they are not there):

extension=pdo_mysql.so

extension=pdo.so

extension=pdo_sqlite.so

extension=sqlite.so

Step 11- Important: The php.ini file is generally directory specific. If you have “PHP5 (Single php.ini)” or “PHP5 (FastCGI)” selected in your Php Config screen, then you should not need to do anything else. If you do NOT have either of those selected, then you may need to copy the php.ini file into all of the sub-folders inside your public_html directory. This may be dozens and dozens of sub-folders that you have to copy the file into. Also, sometimes it can take between 15-30 minutes before the system recognizes the php.ini file or any changes that you have made in the file.

Hope this helps and good-luck with your setup.

Phesto


pix How To Change PHP memory limit for Wordpress About the author:  I am Phesto Enock, Tanzanian male living in Finland, professionally a software engineer, a blogger and online business researcher. I love technology and its wicked twists. I am a main author of NiftyEyeBlog So let us share our experiences. Read more from this author


7 Responses to How-To Change PHP memory limit for WordPress
  1. Tom
    October 18, 2010 | 09:45

    Thanks a lot for this good guide…it literally helped my blogs…

      (Quote)

  2. Jorge Pedret
    March 17, 2011 | 00:07

    Thank you! I was having problems with BuddyPress for WordPress and this solved the problem :-)

      (Quote)

    • phesto
      March 17, 2011 | 01:28

      Hey Jorge, Am glad it helped,
      regards.

        (Quote)

  3. D'house
    October 12, 2011 | 16:28

    Hi there.

    I'm stuck at step number 2.
    The only related icon that I have is PHP Configuration in which when I click on this, it shows the PHP configuration settings only. It states that "These PHP configuration settings are customizable by the server administrator. They are listed for reference only."

    Any kind of help will be useful.

    Thanks in advance

      (Quote)

    • phestoem
      February 2, 2012 | 11:27

      Hi, sorry for replying so late on this, but if you cannot change some of the sections in cpanel, that means you do not have the privileges to do that. You have to check with you main admin, and see what kind of changes you can do, if not, then you might ask them to do it for you. Hope this helps..you or somebody else.

        (Quote)

  4. oscar
    December 1, 2011 | 21:58

    if not I have access to the php.ini file there is another way to solve this problem

      (Quote)

    • phestoem
      February 2, 2012 | 11:24

      You can use some plugins that allow you to tweak the php.ini from the WordPress dashboard. I will have to dig around to find which plugins, you can do the same. Whoever gets that first, please post here, for others to see.

        (Quote)

Leave a Reply

Wanting to leave an <em>phasis on your comment?

Trackback URL http://www.niftyeyeblog.com/how-to-change-php-memory-limit-for-wordpress/trackback/