This article is an answer to a question I got recently, which stated:

When you transfer your site from old domain or localhost to new domain, what are the steps to take and what errors do you need to look for?

Servers In Data Center

While this question is about transferring a domain it also applies to changing hosts. Coincidentally, I did that very thing this week. So to do this we are going to need to do 3 things:

  1. Backup the Files.
  2. Backup the Database.
  3. Point the domain to the proper IP address.
  4. Import the Files.
  5. Import the Database.

A quick note before I explain the procedures. The order of these things matters, not so much on the backup but on the import it can matter a bunch as you will see below.

Backup Files

The files in WordPress are of 2 types, there is WordPress core files which drives the WordPress system. We are not interested in those.  Core files are located in the root of the install. The user files are stored in a directory called wp-content.

Depending upon the setup you have you may see a variety of directories within this one. However, there are 3 directories that we are interested in:

  • Themes stores your theme files.
  • Plugins stores your plugin files.
  • Uploads stores your media files and documents.

I recommend that you make a copy of wp-content so you have everything you need. If you are on a local install, called localhost or 127.0.0.1 (localhost IP address) you already have these on your system. Just navigate to the folder that contains you WordPress installation.

If you are on a host and you are moving to another one, use your FTP client to navigate to the wp-content folder and download everything to your computer. Once you have done this  you can more on to the next step, backup the database.

Backup Database

Backing up the database on WordPress is interesting because there are 2 ways to do this. One is far easier for the average user but it isn’t quite is thorough. The second is more thorough but it is harder and requires more technical knowledge. I am going to show you both methods and you pick which one you want to use.

Easy Way

The easy way uses functionality built into WordPress. This is the recommended way for most users. To access this functionality on the WordPress Dashboard -> Tools -> Export. The system will then ask you what to export and you want to click all content (this should be selected by default). This will download an xml file with all your content. Check your downloads folder and you will see it.

Hard (More Thorough) Way

If you want to do it the harder but more thorough way, then you will backup the entire database. The step we just did above only gave us the content, which is themes, plugins, posts, pages and media files. The database stores more than the content. It still stores all the content but it gives us the full system settings as well.

To backup the database go find PHPMyAdmin in your local server or your host’s cPanel. Once in there select the database you want and click the export button. In the dialog that appears select quick under export method and the dropdown should be SQL. Click Go and the file will download. You have just exported the full database.

PHPMyAdmin Export

Point the Domain To Your Host

Now you need to go point to the domain to your hosting provider via DNS. The DNS translates human readable domains like google.com to an IP address like 1.2.3.4. You are going to need to create an A record with your registrar.

Please note it is very common for your host to also be the registrar but this is not always the case. If your registrar and your host are different companies you need to login to your account with your registrar to point them to the host. However, you will need to first get the IP address from your host.

Once you have your host’s IP address login to your register and go to the DNS section for the domain you want to point. You are going to add 2 A records with the following values:

TypeHostValueTTL
A@IP AddressTime
A*IP AddressTime

Depending upon your registrar’s system the TTL (Time to Live) value may be in minutes or seconds. Just select the shortest option.

Import The Files

Remember earlier I said the order mattered, well now I will explain. I want to you move the files first because the media library will not find the files (and thus will not add them) if you import the data before the files. So I recommend moving the files first. Please note you will need a WordPress install (or at least the file structure) up and running before you can move the files, which I discuss here.

Once the WordPress install is created and your FTP is setup with your host navigate into the wp-content directory both locally and on your host. Move the Themes, Plugins, and Uploads directories from you computer to the host.

Import The Database

Just like above there is an easy way, good for most users, and the harder more thorough way.  I will explain each method.

Easy Way

The easy way will use a feature of WordPress called the WordPress Importer. On the WordPress Dashboard go to Tools->Import. There you will see a bunch of options. At the end of the list is the WordPress importer. Click install and then run the tool. When you run it will ask for the export xml file we dowloaded earlier. This should import all the system data. When you import you may need to reassign content to a user.

Hard (More Thorough) Way

Before you import the database you need to get a fresh install. Using this method you will need to do it manually. Go to WordPress.org and download the files. Extracted the files from the zip and FTP them to your root directory on your host. Now you can move the database.

On your hosts cPanel go to the databases section. Create the exact same name as the database from your localhost or other host. Then go to your new host’s PHPMyAdmin and find the database you created and select it. It should not have tables. Click the import button and import your SQL file. Then install WordPress manually using that database as the database and the same table prefix as the prefix used in the database you are moving.

Troubleshooting

Moving a WordPress website doesn’t always go smoothly. Below is a list of the most common issues I have run into and how to solve them:

  • Issues with the domain: DNS can take up to 72 hour to take effect across the internet. This is why we set the TTL to the lowest value possible. You may need to be patient. Also confirm that your records are pointing to the correct IP address that you got from your host.
  • Cannot install WordPress: This is more common in manual installations. Ensure that your database name is correct and that all the usernames and passwords match. Also ensure that your table prefixes match the previous version as well. If necessary delete all WordPress files get a fresh download and start over.
  • Settings are not correct: This happens when you use the WordPress Importer since it only affects content, not settings. Active your theme and plugins. Re-create your menu and configure your WordPress settings.

Final Results

So now you should know how to move a WordPress website from a localhost or from one hosting company to another. Also you particular host may have migration tools available, so check with them.

There is more to it than this, things like security, SEO, and domain email but this tutorial will get your WordPress website to the right location.

Resources

Root Directory

DNS

How DNS Works

WordPress Importer Plugin

WordPress.org


no2

WordPress is the most popular CMS in the world.  Approximately 25% of all websites use WordPress.  However, there are two varieties of WordPress.  In this article I explain both and why one of them is far preferential to the other.

Two Versions of WordPress

WordPress.com is the first version of WordPress I shall discuss.  Using the .com version of WordPress the WordPress organization takes care of all the hosting and all you have to do is login and create your site.  The result of this will give you a URL that looks like yourdomain.wordpress.com.

WordPress.org on the other hand is also called self hosted.  Using this type of WordPress you would download the latest version from WordPress.org and install it on your web host, which you choose, using a domain that you own.  Since it is so popular, almost any host offers WordPress hosting.  Using the self hosted version, would give your site a URL such as yourdomain.com.

Oh and both versions are 100% free to use. So there is no cost to get WordPress (either version).  That is one of the primary versions it is so popular (that and its really good).

Recommendation

My recommendation is to always use the self hosted version.  It will give you the most professional representation for your organization.  Think about it.  What sound more professional yourdomain.wordpress.com or yourdomain.com?

Also if you use the self hosted version it will scale much better.  For example, suppose your just starting out and you choose the WordPress.com version (yourdomain.wordpress.com).  Then you experience some growth.  How long are you going to want your website to be yourdomain.wordpress.com instead of yourdomain.com?

So do yourself and your organization a favor.  If you are going to use WordPress to build your website, use the self hosted version on your own domain.  And don’t think that hosting is going to break the bank.  You can get some really great hosting packages for little more than a hundred dollars a year.  If this is a concern to you, then you probably can’t afford a website anyhow because you will have many other costs beyond hosting such as development fees, stock photography, email hosting and more.

 

no2