Move or create website on new host
These notes are a checklist for anybody creating a new website at a host other than their domain registrar. A subset of these notes could also be useful for setting up a new website at an existing host (in which case you could skip the section on moving name servers).
How I would traditionally migrate a website from Host A to Host B
Historically, the way I would migrate a website from one host to another would be complicated and prone to mistakes (even following a checklist, because of variations in how hosts implement certain things). It would look something like:
- Take full backup of website on host A and dump SQL database
- Configure name servers at domain registrar to point to the new host B (this if often required before the new host will allow you to configure your domain on their site). This starts the clock ticking, because as this DNS change propagates there is a possibility that visitors will hit the new site, which has not been setup yet.
- On host B, configure the new domain and prepare a folder for the site we’re going to move there. More importantly, if we’ve moved name servers to this new host, we need to put any email forwards back in place as email to this domain will fail until we do.
- Create a new SQL database, import the database dump from host A. If we’re lucky this will work. If this doesn’t populate the database, we may need to copy and edit the database dump from host A and replace the table names from host A with the table names in host B.
- Transfer the website files from host A to host B. If we like lifting rocks we’ll use FTP to do this. However, if we have Cpanel on both hosts and fancy ourselves as clever we might instead:
- download a backup from host A and one from host B.
- Extract both backups and copy the contents of the HTML folder from host A’s backup folder to host B’s backup folder.
- Re-tar and Gzip the backup folder for host B
- Restore host B from the newly created backup (which now includes the website from host A). We now have the website from host A on host B and no FTP client in sight!
- Modify wp-config.php with the connection details for the SQL server on host B
- Update .htaccess on host B to harden access
- Hope that we haven’t forgotten anything.
The process above requires technical skill and attention to detail but if done correctly and quickly (especially after the name server settings have been changed at the domain registrar) results in a migration with little or no apparent downtime to visitors. If all is done well, when visitors’ DNS updates they go from a fully functional Host A (original site) to a properly configured Host B (new site).
The key to having a fully functional Host B is that we’re able to configure Host B without needing website access to it. This is important because we can’t guarantee web access until DNS propagates not just to our DNS server but to the new host’s servers (because WordPress uses internal URLs that may point to the old host if the new host’s DNS has not yet updated).
So, trying to configure a new host through the website itself is difficult until our DNS has fully propagated. Unfortunately by the time our DNS has propagated so has the visitors’ to the website and what they might see if their DNS updates before ours is a website that we haven’t finished migrating yet.
The system described below is a transfer of a website from host A to host B using only a web browser. It is simpler than the traditional method (as described above) but may involve a few hours where your website appears unavailable to some visitors or they don’t see it in its full splendour.
Backup source WordPress website (Site A to Site B)
Once we’ve setup our new website, we’re going to want import our current website’s contents (pages and images). Settings will still need to be configured on the new server. Best that we backup the source website before we start.
- Within WordPress go to Tools\Export to backup the pages of this website.
- Save the XML document to a local folder.
Note that while we can import pages to our new WordPress site from these XML backups, we need the current site to remain up whilst we’re configuring the new website as we copy images directly from the source site to the new site (rather than restore the images from backup).
Point domain nameservers to new web host (Site A’s new home)
There are a number of ways of pointing our domain to our web host (and therefore our website). The most common is to point our name servers to the new host. This means that the new host will manage not only our web traffic, but also our email, FTP and other services.
- Get the names of the name servers for the new domain, such as ns1.newhost.com etc
- Logon to our account at our domain registrar
- Find the name server settings for domain you wish to move, record what they are, then change them to the name servers of the new web host, At this point, your website (and email and other services) will be offline until you have completed the process for configuring the new host. Some hosts require that you have first updated your name servers at your registrar before you can continue to the next steps, so we do it here as a matter of course.
Configure domain and website at new web host (Site A being rebuilt)
This procedure works for setting up CPanel based hosts (such as Godaddy, iFastnet, Byethost etc). There may be some variation between hosting companies but the process is broadly the same.
We will be using Softaculous as the application installer for WordPress.
- Logon to Cpanel at your new web host
- Click on add domain to add the domain whose services you intend to be managed by this host
- Configure MX records so that you can manage email forwarding or accounts
- If you use Softaculous to create your WordPress site it will automatically:
- Install WordPress to your domain folder
- Configure tables in MySQL for your website
- Create wp-config.php with the appropriate connection settings for your website
Standard customisations to newly built Site A
Now that we have created our new (WordPress) website, we will want to customise it to whatever preferences we have for our standard WordPress sites. Mine are:
- Settings\General –
- set site language to New Zealand
- Time zone to GMT+12 (or whatever TZ you’re in)
- Plugins – delete unneeded plugins and add the following:
- amr shortcode any widgest – allows us to place widgets directly in a page (not just in sidebars). I use this for in-page site maps.
- Wassup -gives us details of who is visiting the site
- WPForm – simple forms
- Settings\Permalinks – Change permalinks to Post Name
- Appearance\Themes – Add Twenty Twelve theme
- Dashboard\Updates – check if themes or plugins need updating
The website is now a vanilla WordPress install with WordPress/plugins updated and any customisations that we wish to have as standard.
We can now either start building a new website from this, or import pages and content from another site.
Import pages and (media) content from Site B to new Site A
Now that we have created our new (WordPress) website, we prepare it with standard customisations then import settings from our old site.
- Tools\Import\WordPress – If this is Site A, import the XML backup you made of Site B (which should be a live and current copy of this site). The XML backups do not include images (photos and other multimedia) so in order to get these we import them from the other, live site. If you try to import an XML backup of the site you’re on, that will work for the WordPress pages, posts etc, but you will then attempt to connect to the XML site (which is the site we’re trying to restore TO) to restore images. Obviously they won’t be there (or we wouldn’t be trying to restore them)! This means that if you want to move Site A from one host to another, you must first create backup Site B and import to it (including images), then re-create Site A on the new host and import to it from Site B. This requirement alone is a good reason to always have a live backup site.
- Appearance\Customize (theme) – set static homepage (to your Home page) and background image (if you use one), Set Primary Menu.
- Appearance\Widgets – Configure widgets in the sidebar