How to Move Your WordPress Site to a New Server

How do I move my WordPress site to a new server?

I’ve set out two processes below:

  1. Migrating a site using BackupBuddy (strongly recommended)
  2. Migrating a site manually

Migrate a WordPress website with BackupBuddy

Without question, I recommend using BackupBuddy to migrate a WordPress website to a new server (and domain, if necessary).

If you’re not familiar with BackupBuddy, I wrote a detailed review of it here on my WordPress Security Basics site.

Here are the steps:

Step 1 – Backup your site

Using BackupBuddy, create a full backup of your WordPress site (database and files) and download the backup file to your computer.

Make sure you’ve downloaded the importbuddy.php file to your computer as well.

This can be downloaded by clicking the link in your BackupBuddy > Backups screen and saving the file on your machine.

Step 2 – Import your site to the new server

First step is to create a new database on the destination server, which you can do via cPanel, or whatever control panel the destination hosting provider offers.

Make a note of the new Database name, Database user and password. You will need to enter these during the BackupBuddy site installation steps.

Next, upload both the newly-created backup zip file and the importbuddy.php file to your new server, so that they are accessible from the Internet.

Using your web browser, navigate to importbuddy.php on your new server – e.g. www.yournewserver.com/importbuddy.php – and follow the on-screen instructions.

Be sure to have your database details to hand (database name, username and password).

BackupBuddy will establish your database, install WordPress, import all your posts, pages and other data in your database, and re-write the URL strings (if you’re moving the site to a new domain).

You don’t need to do anything other than follow the on-screen steps.

Migrating a WordPress website manually

In case you’re masochistic, here are the steps to migrate a site manually:

Note that the process I’ve set out below assumes that the server has been set up correctly.

Process for moving WordPress to a new server manually

The big picture

In order for WordPress to operate correctly, the WordPress system files, that are contained in the root folder and the wp-admin, wp-content and wp-includes folders, need to be able to interact with the database.

Therefore any problems you encounter will almost certainly be because they are not able to do so.

The file that enables them to connect with the database is the  wp-config.php  file.

This file specifies settings such as the database name, user and password, the home and site URLs and the MySQL host name (which is usually ‘localhost’).

So if you have any problems this is the first place to look.

You may also come across a problem if you’re moving the site from a sub-directory on the origin server to the root directory on the destination server.

In this case the simplest solution is to locate the  .HTACCESS  file on the destination server, delete its entire contents and replace them with the default WordPress  .HTACCESS  entry.

This is the default WordPress  .HTACCESS  entry for sites that reside in the root folder:

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

Keeping those points in mind will enable you to deal with any problems that arise once you’ve imported the database and uploaded the system files.

With that in mind, here are the steps:

Step 1 – Back up WordPress

Make a full back up of your current WordPress site – database and system files. You will have two files:

  1. A zip file which will be your system files
  2. A  .sql  file which will be your database

I wrote an article with full details and options on how to back up a WordPress site here.

Step 2 – Install WordPress on the new server

Create a new database on the destination server and make a note of the Database name, user and password.

Import the database tables, using the phpMyAdmin screen, by importing the  .sql  file that you downloaded earlier.

If you are migrating the site to a different domain you will need to run an SQL query to change the URL strings on all the tables in the database.

This article describes the SQL query process in detail.

When your new database is installed, FTP your previously backed up WordPress files to your new server.

They will probably go into the  public_html  folder, but get confirmation from the destination hosting provider if it’s not obvious.

You can upload the  .zip  file and use the extract feature in the server file manager to extract the files from the archive. Alternatively, you can unzip the files on your computer before uploading them.

Note that uploading the unzipped files will take a lot longer than uploading the  .zip  file.

Once the files are uploaded, locate your  wp-config.php  file and edit the database name, user and password to match those of the database you set up earlier.

The redacted data in the image below are where you insert the DB Name, DB User and DB Password. Be sure to retain the single quotes at the beginning and end of each entry:

screenshot of DB Details

If you’re migrating to a new domain you will also need to change the  homeurl  and  siteurl  values. (See the article I linked to above for directions on the SQL queries to do that).

When your system files have been set up and linked via the  wp-config.php  file to your database (which has been edited as necessary) you will be good to go.

Typing in the new URL should bring up your site, as long as the domain name server details have been correctly set up and propagated across the Internet.

Installing a clean version of WordPress (the easier option)

Alternatively, you can install a clean version of WordPress.

Installing a clean version is very easy, using either the 1-click installation process your hosting provider offers or installing it manually.

Both the processes I’ve described above (installing new or installing from back-up) will ensure your database is correctly set up and linked to your WordPress files.

After you’ve installed a new version of WordPress you will need to FTP your ‘old’  wp-content  folder to your server to replace the one that has just been installed.

This will ensure the media, plugins and themes you had on your old (current) site are available in your new installation.

Once that’s completed you’re all done for the manual process.

Important

One important thing to be aware of:

If you’re migrating your site from one hosting provider to another there is always the risk of problems occurring because servers can be set up in so many different ways.

While BackupBuddy does have filters built in to take account of different server configurations, it cannot guarantee to have all configs covered.

It would be prudent, therefore, to assume that the servers on your new hosting provider are set up differently from the servers on your current hosting provider – and to be prepared for problems.

If you’re migrating to a different server with the same hosting provider compatibility problems should not occur.

Cheers,

Martin Malden

Martin Malden
Owner – WealthyDragon

Website owner: Martin has been working online since 2006 and focuses on two areas: 1) affiliate marketing and 2) designing and building websites based on WordPress. He has his own WordPress agency, and serves clients in Hong Kong, Australia and the UK.

What do you think?

Comments on this entry are closed.

  • Wordpress hit counter Jan 22, 2011 @ 2:27

    Great post.Even your article of getting backup of wordpress is also excellent.I needed that solution from long time and now i got it.Thanks for sharing.

    • Martin Jan 22, 2011 @ 7:36

      You’re welcome – glad it was useful,

      Cheers,

      Martin.

  • Shailender @ Valentine Vacation Jan 22, 2011 @ 18:00

    I must say that you have come up with very informative post. And you certainly did a great work in preparing this post. I think lot of people don’t know about this. Keep up the great work. 😀