Wordpress

How to Permanently Fix WordPress Memory Exhausted Error in VPS

Recently, I upgrade my hosting account from a share hosting to a VPS system. I manage to get a very good deal from TurnKey Internet through their Black Friday 2011 sale.

After setting up the server, I started to move my wordpress blog to new VPS hosting. I restore the database & all the files. I checked the blog & everything function wonderfully well with a better speed.

I try to enter the admin page, but I was greeted with the following error message.

Fatal error: Allowed memory size of 33554432 bytes exhausted
(tried to allocate .....)

After a search through the internet, I found the solution by placing the following code in “wp-config.php” file under the wordpress directory.

define('WP_MEMORY_LIMIT', '64M');

However, I feel it is not practical to change one by one for all my blogs.

If you have VPS system with WHM/Cpanel, you can fix it permanently by

    1. Log in to WHM
    2. On the left-hand side menu, locate “Service Configuration” header
    3. Click on “PHP Configuration Editor”
    4. In the “Basic Mode” find the following line
Section Directive Info Value
Core memory_limit This sets the maximum amount of memory in bytes that a script is allowed to allocate. This helps prevent poorly written scripts for eating up all available memory on a server. Note that to have no memory limit, set this directive to -1. 32M
  1. Change the “Value” from “32M” to “64M”. Take note on the capital “M”
  2. I should fix all wordpress blogs in the same VPS

How to do Bulk Replacement of WordPress SQL Database

Imagine that you have many similar typo errors in 100′s of your post such as ”[email protected]” text. The text is very important that you have to correct it with “[email protected]”.  Are you going to edit all your 100′s post one by one?

Trust me, it won’t be fun. Fortunately, there is an easy way to do bulk data replacement in WordPress SQL database. Some people call it “Search & Replace” method.

Remember to backup your database prior doing this.

To do this simple log in to PHPMyAdmin. Select the correct database & click on SQL tab. Use the following code to do the bulk replacement.

UPDATE wp_posts SET post_content = REPLACE (
post_content,
"TEXT TO REPLACE",
"REPLACEMENT TEXT");

Change “TEXT TO REPLACE” with your old text to be replaced & “REPLACEMENT TEXT” with your new text. Remember to leave the open & close quote.