How to migrate a site from one host to another
If you’re unsatisfied with the service provided by your current web host, you can make the switch to a new one. This process can be a bit of a pain if you choose to do it manually (you can also opt for a host that’ll do it for you), but in this guide we’ll help you through it to ensure that the transition is smooth and that your downtime is minimal.
Purchase web hosting with a new host.
But don’t cancel your old hosting plan yet! This is a common error, and can have serious consequences, not only in downtime, but also in a total loss of your files and database information in some cases. To avoid this, first purchase a new hosting account, transfer your files, migrate your site and even let the site run for a couple of days on the new host’s server just to ensure everything’s functioning as expected. And only then, when everything is working properly, should you cancel the old plan.
Move files, databases, and email accounts
After purchasing your new hosting plan, the next step is to transfer all files, databases and email accounts to the new server. If you have a static site, your life will be a bit simpler. You’ll just have to download your files from the old host and upload them (consistently with their file structure) to the new host.
A dynamic site with a database (like MySQL) is a bit more involved. First, download your files to your computer and store them in a safe place. Make sure that you have each file backed up. You can use an FTP (file transfer protocol) app like FileZilla, Smart FTP or Serv-U to download html files, graphics, etc. Or if your old web host has cPanel, you can export your database easily to your new web host using phpMyAdmin.
If your website uses a Content Management System (CMS) like WordPress, make sure to install that CMS on your new web host before transferring the database. WordPress has a simple import/export function, allowing you to transfer data files directly, but some CMSs are a bit more complicated. If you use WordPress on cPanel, just zip all files in your “public_html” or “www” folder, then upload that folder to the new host, adding these lines of code:
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST']); define('WP_HOME', WP_SITEURL);
You’ll also need to import your email accounts to the new server. It’s a good idea to create a catchall email address if you have many accounts - that way, if you forget to import one, the mail won’t bounce. You also might want to create two accounts for each email with the IP of both your old and new mail servers in the POP rather than the domain name.
Test your website on the new server
After importing all of your files, make sure that everything works properly. Your new server should give you the possibility of testing performance in a development staging platform with a temporary URL. Check for performance, consistency in layout and functionality of links. It’s important to catch any issues at this phase so that the transition is as smooth as possible.
Note that your MySQL database usernames, passwords and permissions won’t get automatically downloaded in your database backup files. Make sure to save and re-enter all of this information on the new host in cPanel’s MySQL interface.
Switching DNS Records
The final step to switching over to the new host is to update your domain name records. Your new host will send you information about DNS alterations after purchasing the plan, and you can make changes from the control panel of your domain registrar. Before changing, be sure to change the database strings from your new host’s control panel.
These changes typically take effect in 12-24 hours, although your site will continue to be fully functional during this period (both the old and new sites).
Only after completing this step should you cancel your hosting plan with your old provider!