(+84) 463.28.7979

Moving Your WP Site


This post has instructions for moving your WP site – to a new server, to a new domain, or from a development server.

1. Moving to New Server, Keeping Same Domain

If you find you need to move your domain to a new server (which WPWeaver.info did recently), it is fairly easy to move your site. The article available at WordPress.org, Moving WordPress to a New Server, pretty much covers it.

The only warning is that when you change servers, you will experience a delay (a couple of hours to up to a day or more) while your new site’s real IP address is propagated to all the DNS servers, and your site will not be available during this period. Seems to be no way around this.

2. Changing Domain Name, Moving from a Development Server

So you’ve been developing your site on a development server – a place where the site’s domain name is not the final name. Or you want to change your domain name. This process is somewhat more difficult. I’m not entirely satisfied with the WordPress.org explanation of this, so here is my (longish) description of making this move. (I have a few specific references to bluehost.com, but any other host worth using will have similar tools.)

1. From your running local site (or site running on a different domain), use phpMyAdmin to download a copy of your sites mySQL database used by WP. This is a very important step – this database has all your pages, posts, and other site info. When you download the file this way, you end up with a text file (with an .sql extension) on your local machine. At this point, you should not make or allow any changes to your existing site.

2. Now, create the directory, if necessary, for your site on your host. In the case of Bluehost, the primary server is on the root directory (the root of public_html). If that directory already had some file that won’t be a part of your new site, delete them. Best to start with a clean slate.

3. Using ftp or cPanel file manager, upload ALL the WP files from your local PC. (If you were moving from another domain on another host, you’d need to download all the files to your PC first!). This may take a while, but will ensure that you get ALL your media files, plugins, etc. installed on the new site.

4. Create a new (empty) mySQL database for WP to use. You need both a database, plus a database admin account to do this. This is done using the mySQL Databases utility from cPanel (or something similar on other hosts).

5. Edit the wp_config.php file contained in the site root directory. (You can use the cPanel file manager, which has an edit option to edit that file.) Change the appropriate stuff – the database name, the database admin account name, and the database account password (will be in the clear in the file, but only people with admin access to your account can see it!). The database host is localhost on bluehost. It might be different on other hosts. (See Editing wp-config.php.)

Don’t try to access your new site yet – you would just get WP’s attempt to get you to create a new database.

6. Now the “tricky” part, and the main thing you have to do to get your new site working on its new host and new domain name. Make a copy of the mySQL database you created in step 1 (just to be safe!). Now, using almost any text editor (textedit on a mac, the equivalent on Windows), open that .sql file. You should now use the search and replace command of the editor to replace every instance of your old website’s base url with the new one. For example: Replace all instances of ‘http://olddomain.com’ with ‘http://newdomain.com’. (If you’ve use any e-mail addresses at the old domain, or have references to just the old domain, you should update them, too.) Save that file.

7. Now, using phpMyAdmin from the new site, upload the .sql file you just edit into the new, empty mySQL database you created in step 4.

8. You should be done, and your new site should be fully functional operating under the new site’s domain name. Any links you made to media files, or other parts of your old site should now work with the new site (that’s what the edit of step 6 did – fixed those).

That’s my explanation. Here is the relevant excerpt of what is found on the WordPress.org site itself about this kind of site migration. Doesn’t hurt to get two versions of the same operation!

Begin by backing up your data. This includes backing up your WordPress database as well as all the core files, images, plugins, and other files on your site. See WordPress Backups and Backing Up Your Database for more details.

Make a copy of your database. You will need to edit the .sql file, and in case of errors, it is important that you work on a copy.

Begin the process of working from copies of your backups.

If you have changed domain, edit the backed up database file to reflect this. A simple way to do this is:
1. Using a text editor, open a copy of the .sql database file.
2. Using the search and replace function, find all instances of the blog’s old URL and replace it with the new URL.
3. Repeat the process with your old email address. (For example, replacing someone@example.comwith someone@tutorial.com)
4. Save your changes.
5. Upload your plugins and themes from your old site to the new one.
6. Drop (delete) the database tables of the target web site.
7. Restore the database.

When you are ready to check your site, make sure to clear your cache and cookies so you will see the changes in your web browser.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>