How do you seamlessly switch hosting?

I recently switched a WP site from shared hosting to a VPS and would like to document the process here.

Put old host in read-only mode

  1. Go to WP Admin -> Settings -> Discussion and check “Users must be registered and logged in to comment”
  2. Disable authentication:

Create a PHP file inside the wp-content/mu-plugins folder, with the following content:

<?php

function wp_get_current_user() {
    return null;
}

This will prevent all logged-in users from leaving comments or creating posts on the old host.

Copy files and database to new host

I used FTP for transfering files and phpMyAdmin for exporting/importing the DB.

Handle DNS

  1. Point your domain to the new host’s IP address.
  2. Wait for propagation to take place.

Once the new DNS settings have propagated fully, you can nuke the old host.

Just wanted to add if you change the TTL you won’t have to wait as long, many hosts have a TTL of up to 24hours, you can set this to 5 minutes before the big move and then back again after ( or don’t the server will usually auto set it back to defualt since they don’t want you pinging every 5 minutes).

Revisions

There are no revisions for this post.

Tags: ,

No comments yet.

Leave a Reply