Copying WordPress to a New Server

by steve on December 2, 2009

Let’s say you’ve got a WordPress site on one server, and you need to move it to an entirely different server that’s going to have a different URL than the current one?

C.K. Sample has some helpful instructions here.  (Should his site go down, you can view this page as an image here.) These are very useful, but they assume the new server has the same URL as the old one.  After you restore the database, you’ve just broken your new site because the settings refer to the address of the old site.  Not so hot, but not too hard to fix.

Here’s the trick.  You follow C.K.’s instructions through Step 7.  That’s the step where you restore the database.  Once you’ve done that your new site is broken.  If you’re a lucky person (and many of you are) you’ll have access to a GUI database on your web server.  phpMyAdmin is very common, there are others or you could edit your database from the command line – which is guaranteed to impress the chicks.  I’m not going to teach you how to edit your database in this post, but I’ll tell you where to go.

Once you’re editing the database your WordPress installation is using open the table called “wp-options“.  Inside there is a field called “siteurl“.  Edit that field and put in the correct URL for your site.  (ok, in phpmyadmin, first click select the database you’re using with WordPress.  Then click on “wp-options” in the left-most list.  Then you’ll need to click “Browse” from the horizontal tabs across the top.  Now you should see a list of fields and the data that is stored in them.  As of 10/2010 you should see “siteurl” near the top of the list under “option_name” and the URL of your site under “option_value”.  Click the little pencil that is on that line in the table.  This should bring you a screen with an HTML text area with the URL for your site in it.  Correct the entry and click the “go” form button.  Feel good about yourself for messing directly with the database.)

Now go to wp-admin and log in as admin.  Go to Settings -> General.  Make sure that the “Blog Address” entry is correct.  Once you’ve got that right your site should just work!

The settings for WP-DBManager are probably also wrong, as they point to wherever things were on your old server.  You’ll want to go and update those now too.  One more thing to check.  Go Settings -> Miscellaneous.  You’ll want to make sure that the “Store uploads in this folder” setting points to the right place on your new server.  If it doesn’t anytime you try to add an image (or any file) to your site you’ll get an error message about not being able to create the directory.

Yet one more thing – if you’re copying a site you’ve kept secret in development, you may need to change your privacy settings to alert Google, etc to look you up. That’s in WordPress wp-admin > settings > privacy.

Now you’re done!  Good work!

Comments on this entry are closed.

Previous post:

Next post: