This will technically work with most single-server applications (if you don’t know the difference then you’re probably on a single-server set up), not just WordPress, but as WordPress is pretty popular I’ll talk through that instead.
Moving to a new host can be a little unnerving. If all goes well your visitors would never know, but on the flip side it can all go terribly wrong very quickly, and there is a lot that can go a miss. This is a step-by-step guide on how to move your WordPress website from one host to another with no downtime.
Before we begin I’ll assume you have your two hosting environments ready. Your original hosting environment (we’ll call that environment A) and your new hosting environment (environment B).
1. Begin downloading a copy of your site via FTP. Download all the files to somewhere safe on your computer.
2. Upload these files to your new host, environment B.
3. Open the wp-config.php file and find the lines that list your database connection info.
4. Take a copy of your original site’s database. You can usually do this by logging into cPanel, Plesk, or whatever control panel you may have for your hosting on environment A, and then going into phpMyAdmin (Export tab).
5. Create a new database and user if you don’t already have one – on environment B.
6. Edit your local copy of the wp-config.php file with these details. They may be the same, but they may not be.
7. Upload this file to environment B and overwrite the existing file.
8. Ensure the wp-content folder and subfolders are writable. This is usually done via FTP by right-clicking the folder and selecting File Permissions. Different FTP clients vary.
9. On environment B’s control panel, log into phpMyAdmin and Import the export from environment A you just downloaded in step 4.
10. Ensure you can accept remote database connections on environment B. If you’re using cPanel, there is usually an option for this. If not, ask your hosts.
11. Change the wp-config.php file on environment A. The DB_HOST constant should be set to the IP address of environment B.
12. Change your DNS to point at the new server.
Why do this
Doing the transfer this way means that you have 2 sites set up, both on different hosts, both exactly the same except for one key difference: Site A uses Site B database. Anyone visiting your domain will see site A, but still uses site B’s database. Any changes made are all made to the same place.
When you change your DNS these changes are not instant. When you make a DNS change you’re often told that changes can take “up to 72 hours” – this is probably a little far fetched, but it can often take 24 hours depending on your ISP. That’s a 24 hour window where some users see the old site and some see the new site, the last thing you want is a data miss-match.
Because of this, you’ll want to be as fast as possible between steps 4 and 12. It shouldn’t really take any longer than 15 minutes to do the whole process. You can always manually check your old database for updates though, of course.
And lastly… This does not account for file uploads during the DNS transfer window. Those files will always be uploaded to whatever server the users’ DNS looks up. A work around for this will be to place your old site in maintenance mode once you have made the DNS change, which will show any visitors to the old site a message asking them to return shortly – this would only effect a small percentage of your visitors though.