Everything Else

How to Move Your WordPress Blog to a New Web Host

There may come a time when you will want to move your WordPress blog to a new host.

Often there may be a number of reasons why you would want to do this.. including,

  • poor customer service from your current web host
  • a need to move onto a plan that allocates more server resources, eg from a shared server > VPS or dedicated  server
  • more competitive price
  • special promotion

There are quite a few factors that need to be addressed prior to, and during your move.. that can help to make this transition relatively stress free.

I have successfully completed my first move onto a new web host.. and this article is my first post since the migration.

These are steps I took, pretty much in chronological order.

Feel free to follow the same process or skip sections as you see fit.. hope fully your move will be as pain-free as mine was.

Prerequisites and Assumptions

This post is based on the following prerequisites and assumptions,

  • I will refer to my old web host as – old web host
  • I will refer to my new web host (i.e. web host I am moving to) as – new web host
  • You have some FTP knowledge
  • Both web hosts have cPanel installed on the plan selected
  • Familiarity with cPanel / phpMyAdmin
  • You have already chosen a new web host
    • your new account is setup
    • you have been given a new temporary URL
    • you have been given your new FTP details

Initial Preparation – Old Web Host

Plug-ins

If you have a caching plug-in like W3 Total Cache or WP Super Cache on your old web host, I would recommend deactivating > then deleting it.

But before you do this, make sure you take screenshots of all your settings.. to make the installation on your new web host easier.

You probably don’t need to do this, but it just eliminates an extra variable (ie with cached pages) when setting up on your new web host. Better to be safe than sorry.

You should also disable and delete all other non-essential plug-ins.

Make sure you take screenshots of any plug-in settings before deleting!

Backup using cPanel

Backup EVERYTHING! I can’t stress this enough.

Using cPanel on your old web host you should perform a,

  • Full site backup
  • Home directory backup
  • MySQL database backup
  • Email backup (forwarders and aliases)

Save these backups somewhere on your local hard drive.

If something goes wrong, you can always revert back to these backup copies!

Backup using FTP

Once you have performed these backups using cPanel, you also need to backup your entire site’s structure (folder, files, permissions) using FTP.

This may take a while depending on the size of your site.

Save this backup of your site’s structure somewhere on your local hard drive.

Database

You need to find out the database nameuser and password of the database of your old web host.

You can find this in the wp_config.php file that you have just backed up.

The location of this file is listed further down this article.

Create a New Database – New Web Host

The first thing you need to do is create a new database on your new web host.

Using the temporary URL your new web host has provided you, log in to the cPanel of your new account and click on MySQL Databases,

You will then need to,

  1. Create new database
  2. Add a new user
  3. Add new user to new database

Take note of these details as you will need them again shortly.

Updating Old Database Details with New Database Details

You now need to assign the details of this newly created database name, user and password.. to some files that you backed up earlier (from you old web host) on your hard drive.

wp_config.php

The wp_config.php file needs to be updated with the details of the new database created on your new web host.

Go to your local backup copy that you FTP’d earlier and find the file wp_config.php located,

  • /wp-config.php
  • /public_html/wp-config.php
  • /public_html/wp-config.WPTunerFinal.php (you may/may not have this file)
  • /public_html/wp-config.WPTunerOrig.php (you may/may not have this file)

Open each of these files using a text editor like NotePad++.. and look for the database nameuser and password,

Now replace each one with the details of the new database that you created on your new web host.

When you have added in the new database details, save each file.

MySQL database

With the MySQL database backup you did earlier.. you now need to find all instances of your old database name, user and password and REPLACE them with your new database details.

To do this you will need to unzip your backed up database.. then open it with a text editor like Notepad++.

Using the Find and Replace (Control + F) function.. you will need to,

  1. Find <old database name> and REPLACE it with <new database name>
  2. Find <old database user> and REPLACE it with <new database user>
  3. Find <old database password> and REPLACE it with <new database password>

Then click on <Save> to save this file with your new database details.

The Big Move – Migrating All Your Files

Now that all of the prep work is done, you need to import/transfer these files across to your new web host.

Import Database

You need to import the database that you have just modified (on your hard drive) with the new details.

Log in to phpMyAdmin on your new web host, click on Import > select the database on your hard drive to import.. then click on <Go>,

If your database is very large (> 50MB), you may have to get assistance from your new web host to upload/import.

Import Email

Upload the backup copies of your email forwarders and aliases by clicking on Backups > Restore (via cPanel).

Upload Site

Now upload the backup copy of your entire site (all folders and files) to your new web host via FTP.

Depending on the size of your site this may take some time.. go and grab a cup of coffee.

Configuration – Getting your New Site Ready

Now that you have uploaded your database and site’s files and folders to your new web host.. there is still some configuration to do.

You now have two sites.. your live site.. which still sits on your old web host.. and the site you are migrating to, which sits on your new web host.

If you browse to the temporary URL given to you by your web host, in my case http://203.123.59.225/~thesocia/ you will notice that your homepage still does not show up.

That is because your database (on your new web host) still thinks your homepage is your live homepage.. when in actual fact, the homepage you really want, is your temporary URL.

wp_options

You need to edit a couple rows within the wp_options table and tell your new web host that your homepage is now your temporary URL.. and not your current live URL.

That way you can may changes and work on your new site.. prior to going live.

To do this go to your phpMyAdmin > Select your Database > check the wp_options row > select browse,

Look for the siteurl row..

This row should have the URL of your website –> change this to your new web host’s temporary URL,

Look for the home row..

This row should also have the URL of your website –> change this to your new web host’s temporary URL,

These changes tell your database to look at the temporary URL, instead of your live URL.

You can now work on getting your new site up to speed..

Permalinks

Once you have uploaded your database and entire site.. go to your homepage (temporary URL) and click on any link,

You will most probably get an error appearing similar to,

If that is the case you need to ‘toggle’ your permalinks.

Under Settings, click on Permalinks,

Your permalink settings will now be displayed,

Now select a different permalink setting.. then click <Save Changes>,

Now toggle back to your original permalink settings.. then click on <Save Changes>,

Your post should now display,

Plug-ins

Any plug-ins that you deleted prior to the migration, can now be re-installed and re-configured on your new web host.

I use a caching plug-in called W3 Total Cache.. I re-installed this, but didn’t activate it.

To eliminate any issues that caching may cause.. I activated this plug-in once my site was 100% operational and live.

I did install an extra plug-in called Search and Replace.

This plug-in allows you to search for strings in your database, and replace..

I did another search through my database of my,

  • old database name
  • old database user
  • old database password

.. just to double-check that I had replaced these with my new database details.

Upload Path

Another thing to check is your upload path.

Go to Settings > Media,

Under Uploading Files.. check that the upload path is correct.

It should now display the path to the uploads folder on your new web host.

The correct path will display the prefix of your new database name (not the prefix of your old database name),

Missing Images on Posts – Hosts File

The big thing with moving to a new web host is that (for me) most of the images in my posts were missing,

I queried this with my new web host and this issue has something to do with received the following reply,

If you are trying to preview any sites that use rewrites (WordPress and Joomla are classic examples), it will not work via the temporary address.

What you will need to do is edit the ‘hosts’ file on your computer to trick your computer into thinking that the domain name really resolves to 203.123.59.225 and not it’s current IP of 27.111.92.24

The hosts file is a plain text file.

On Windows XP the file resides in C:\WINDOWS\system32\drivers\etc (on other versions of windows it would be in a similar location).

Open it with something like notepad and add the following:

203.123.59.225 thesocialmediaguide.com.au www.thesocialmediaguide.com.au

Restart your web browser and test.

If the hosts file entry still isn’t overriding the DNS lookup, you can try clearing your DNS cache by issuing the “ipconfg /flushdns” command from a command prompt (worst case scenario, restart the PC if it wont play nice).

If you are on a Mac/Linux/Unix variant, the hosts file is at /etc/hosts

You can use this method to test sites that use rewrites (mod rewrite) prior to delegation to see if they work properly.

Can you please try this and see if it resolves your issue?

If it does and you are happy with the result, you can remove the hosts file entry.

Please let us know if we can be of further assistance to you.

After implementing the above advice regarding the hosts file.. I found that the images in my posts were still NOT APPEARING.

So I decided to press forward and “hope” that when I delegated my name servers (see next section), this would resolve the issue of images not appearing with a temporary address.

And it worked!

After the name server delegation.. all images that were previously not appearing in my post.. were now appearing,

Apparently WordPress doesn’t like temporary addresses when it comes to displaying your images.. but after you delegate your name servers, they will appear (as shown above).

The Final Cutover – Name Server Delegation

wp_options

When you are ready to make the final cutover from your old web host to your new web host.. you will need to change the temporary values (i.e. URLs) in the wp_options table back to the URL of your website.

To do this go to your phpMyAdmin > Select your Database > check the wp_options row > select browse,

Look for the siteurl row:

  • This row should have your new web host’s temporary URL (that you changed earlier) –> change this back to your blog’s URL.. eg http://thesocialmediaguide.com.au

Look for the home row:

  • This row should also have your new web host’s temporary URL (that you changed earlier) –> change this back to your blog’s URL.. eg http://thesocialmediaguide.com.au
Maintenance Mode

I would recommend installing the Maintenance Mode plug-in on your old web host.

When activated, this plug-in lets people know that your site is undergoing maintenance by displaying a custom message to any visitors during this period.

It is also a good way to witness the DNS transition for yourself.

Initially you will see your maintenance page.. then sometime later when your actual homepage displays, you know that your domain has updated and is now pointing to your new web host.

This is optional, but definitely an easy way to see the transition..

Name Server Delegation

Once everything has been configured and you are ready to make the final move to your new web host.. the final step to perform is known as name server delegation.

This is where you enter the name servers of your new web host against your domain name.

To do this login to your domain management console (if you don’t know just ask your old web host).

Your interface will be slightly different to mine.. but click on the Nameservers link,

Delete the URLs pointing to your old web host‘s name servers,

Enter the URLs pointing to your new web host‘s name servers (your new web host will provide you with this),

Now enable the maintenance mode plug-in on your old web host..

Name server delegation may take anywhere up to 48 hours to take effect.

Surprisingly.. I enabled this at about 10pm.. and when I checked my site again at 5am the next morning (7 hours later).. my site was now live on my new web host,

Test, Test, Test

Once your site it now pointing to your new web host, make sure you do some tests to make sure things are as they should be,

  • test pages appear
  • test (random) posts appear – new and old posts
  • verify that your temporary URL no longer appears
  • verify images appear in posts
  • verify that your permalink structure is correct
  • verify tag links work
  • verify category links work
  • verify links pointing externally work
  • verify that you can log in to your dashboard
  • verify that page number navigation works
  • etc.

I would also recommend toggling your permalinks again (see above).. just so that your URLs are rewritten.

You can now activate and re-configure your caching plug-in..

If you have any issues please contact your new web host.

Then finally.. do a full backup.

Done!

Now that you know how to move your WordPress blog to a new web host.. you have complete freedom to move around as you please. You are no longer bound to just one web host.

If you have any feedback or questions regarding moving WordPress to a new web host.. please leave a comment below.

Related Articles

Back to top button