Saturday, November 25, 2017

Switching web hosting companies (and database and email hosting)

This week I had to switch the web and database hosting company for a client's web site.  The original host (Intermedia) was discontinuing their web hosting service.  The company they tried to transition our site to (Hostway) was very slow in transitioning our site and in their support responses, so we decided to go to another host, A2 Hosting.  They have a Plesk control panel, which I hadn't used before.  I like the idea of using a control panel that is used by more than one hosting company rather than a proprietary one, so that's just one of many reasons we chose A2.

The whole process of switching went well, partly because of the robustness of the Plesk control panel.  Since there were a lot of steps, I wanted to document them here for myself and others who might be switching hosts.  These steps are mostly not specific to any web host, either the original or the destination.  They're also mostly not specific to a platform, Window or Linux, but this happens to be a Windows environment.  I will add a few notes related to how to do these things on Plesk, but hopefully you can find an equivalent if your new host's control panel is different.

1) Open new hosting account.  They will ask what primary domain name you'll be using, but it doesn't have to be registered at the web hosting company.  After starting the account, you should get temporary web and ftp addresses.

2) Enforce a freeze on making web page updates on existing site.

3) Make a database backup of current site.  Its harder (in my case anyway) to enforce a freeze on the database, so this is just a temporary backup to get the new site running.  The final backup will be made later.  For MS SQL Server, this would be a .bak file

4) Download all files from original web server.  This can take a long time, depending how big your site is.

5) Upload all files to new web server

6) Restore the temporary backup to the new hosting environment.  In Plesk, they call this uploading a dump.  Uploading the .bak file retained all of the user logins for the database, BUT those logins still are not logins on the new server, so they didn't actually work for logging in.  So I had to...

7) Delete the logins that were created by the upload and recreate them, specifying the passwords.  (If you added the SQL logins before ever uploading your backup, then I guess you'd save the step of deleting the ones automatically added, but that wasn't a big deal, so I'd probably do it the same way again next time)

8) Change your database connection strings in your code to point to the new server.  Of course only upload those changes to your new server, not your original one that is still the live server at this point.

9) Change the email / SMTP server used to send email via ASP.Net.  More specifically, you will probably need to change the host used by the System.Net.Mail.SmtpClient object. A2 also requires credentials for any mailbox created in Plesk that is a true mailbox with Control Panel access, not just a forwarder.

10) Update folder permissions to give Write access on any folders where uploads are received.  In Plesk, use the File Manager.  When you see the folder listed on the right side, scroll all the way to the right to get to the button that allows you to Change Permissions.

11) Move any SSL certificates.  This involves
a) Generate a new certificate request at the new host
b) Go Rekey your certificate wherever you purchased it.
c) Download your new rekeyed certificate from where you purchased it
d) Upload the new certificate file to the new host
e) In Plesk, there is an additional step to go to your web site settings and specify that the SSL certificate to use for the site is the new one that you just uploaded

12) Create all mailboxes.  If you have email mailboxes on your original server, then you need to create the same ones on the new server with the same forwarding settings, if any.

13) Create all domain pointers.  On Plesk, these are called Domain Aliases.  You'll need one for each domain that will have its name servers pointed to the new host.  i.e. probably any domain that you displayed in the browser address bar for different parts of your site.

14) Test your new server using the temporary URL provided by the hosting company.  For Plesk, the temporary URL looked like http://111.222.333.444/plesk-site-preview/ .  That extra "plesk-site-preview" in the path did mess some things up, and the hosting company actually recommended changing your hosts file instead for testing to point your domain to the IP address of your server.  Be sure to test different content types, such as ASP data-reading pages, ASP data-writing pages, ASP.Net data-reading, ASP.Net data-writing, video formats, etc.  You also could run into issues if the new server uses different versions of software than the old server.  For example, our new database server was MS SQL Server 2016 and the old one was MS SQL Server 2012. It didn't affect the site, but I had to upgrade my SQL Server Management Studio (SSMS) in order to connect to the newer version.

Now all the pieces are ready, so you just need to make the final switch

15) Turn off database updates.  For our site, this basically means take down the login form.

16) Get a final backup of the live database

17) Restore the final backup in place of your temporary one.  In Plesk, if you just Upload Dump again for the new file, it will overwrite the original database.  This is actually pretty scary and I'm surprised there weren't more warnings that you are about to wipe out the original database.  But in this case, it was just for testing anyway.

18) Repoint the name servers of all your domains to the new host.  Once you repoint name servers, they say it can take 24-48 hours to take effect, but its usually pretty much instant, at least for web traffic.  I found that email traffic did take longer to get redirected.  We also had many other domains that just had web forwarding set up to forward to our main domain, so those did not need any updating.

That's it.  A long list, but hopefully no individual step is too hard.  Unless you run into problems while testing.  Good luck!

No comments:

Post a Comment