Migrating WordPress to AWS Lightsail (and other related changes) – Part 1

As some of you will know, my position with my current employer has recently been “disestablished”. I won’t go into the story around that, at least at this point, however as part of my preparing to leave I’ve been working on moving all my services away from said employer (an ISP).

Besides the obvious Broadband, I’ve got 2 websites (well, more than 2 but only 2 I’m going to keep alive) and a number of domains, as well as some email hosting. Moving all this has been a bit of a mixed journey and although it’s still going on, I thought I’d start putting together a bit of the story, challenges, lessons, solutions etc. for anyone else who is looking at moving such things for themselves.

After getting part way through this article, I realised how long it was getting, so I’m going to break it down into parts. Part 1 will be websites, part 2 will cover the rest.

TL;DR

I moved 2 WordPress sites to Amazon Lightsail, mail to Google GSuite, and domains are still a work in progress with domain hosting being a mix of AWS Route53 and Lightsail, and domain registration being AWS Route53 and Domains4Less. Do you want to know why? Read!

The story

After 11 years at my current work, I’d just tended to keep all the things I could in our systems. Partially because I built said systems so had great control/flexibility/etc. and partially because, for the most part, it cost me nothing. So as part of leaving, rather than keeping everything in place and paying their advertised rates, I decided a move was necessary!

For the purpose of this post, I’ll concentrate on 2 domains. The first one “randominsanity.net.nz” (AKA, this site) is my personal stuff, blog, email, basic. The second is a business domain “saferhomes.nz” (A company I’m a co-founder of). For both, we’ll look at domain, website and email (not necessarily in that order mind you).

Websites

As the generally larger part of the project, I started looking for a new web host first off. Both the sites I’m dealing with are WordPress, currently hosted using Plesk on my employers’ web server.

I looked at various locations, both web hosting and straight out VPS, with varying cost and resources. I liked the VPS idea in that I could probably just run both sites (they are pretty low traffic) on one server; I’ve certainly got the sysadmin skills to run the server and manage all that so why pay for someone else doing that stuff! In the end VPS still looked like it would end up more expensive than just outright hosting in many instances.

Due to already evaluating AWS for another project recently, this was one of the places I looked, almost out of pure curiosity more than serious intent. While the pricing on AWS can be quite hard to piece together, best I could tell I could probably do what I needed within their free tier (at least for the first year) and costs wouldn’t be tooooo huge beyond that.

So, I could setup a server on EC2, run a MySQL database on RDS, and even do a bunch of my DNS on Route53 (we’ll talk more about DNS soon). Appealing, not overly difficult concept, and just enough new stuff to make it an interesting challenge. However, as one might imagine, with less than 4 weeks of employment left, a job hunt in the works, a mortgage and all the other bills one acquires as part of being an adult, I came to the conclusion that I wanted something a little faster and easier, with less thinking.

Still, AWS had strong appeal as I wanted to do more there in future. Then I spotted Amazon Lightsail. Almost a sub-service of AWS, accounts linked but designed to be nicely functional for those not dealing with the normal AWS console. Lightsail touts a low-end plan of $5 (US) per month and the ability to deploy a pre-configured WordPress site, which I took an educated guess I’d be able to migrate my current sites overtop of without too much effort.

So Lightsail it was.

I started with my personal domain as a guinea pig first (experiments are rarely good on business domains). A new AWS account was easy to setup, and jumping over to Lightsail I had a generic WordPress site going in about 5 minutes flat.

Lightsail gives you a dedicated IP address for your container (I consider their deployed site/server as a container – maybe I’ve just been playing in the docker space for too long) which you can use to access your website before sorting any DNS; a nice way to be able to prep the site before migration.

The first gotcha I realised in Lightsail is that although you get a public IP, it’s my understanding (from reading rather than having his the issue) is that the IP they allocate is dynamic, which I assume means either that a new IP may get allocated of you restart the container, or (and this is probably more likely) that it’s a little like EC2 where you could kill and redeploy the container but you’d lose the ability to get the same IP again. While the latter wasn’t a major likelihood for me, in case it was the former, I made use of the easy spot in Lightsail to create a Static IP which I can then point to my container and use henceforth. A quick note for young players, while the Static IP is free (for up to 5), it will get charged if you don’t have it attached to a container!!

Okay, so I have WordPress running and accessible… now how to get all my content across?

I had a quick go with WordPress’s inbuilt export/import. That moved all my posts across just fine, but then the theme I was using no longer seemed to be available from WordPress. Cool, copy the theme directory over… nope, seems I’d done some customisation of the theme which I couldn’t recall, so the theme looked quite different out of the box.

Right, plan B (there’s always a plan B, and as is often the case, it was Google). Rather than reinvent the wheel, a quick Google confirmed I wasn’t the first to have this mission (Shock!), nor the first to document a little of the journey for the benefit of others. You can find the article I read here, but basically there is lovely plugin for WordPress (All-in-One WP Migration – love the creative naming) that does a really good and complete site export/import. Install the plugin at each end and follow your nose!

The one trick I did find during export was that since I was keeping the same domain, under the advanced options on the export screen I selected “Do not replace the email domain” as well as “Do not export spam comments”. Other than that it was plain sailing!!

Saferhomes.nz was pretty much identical. Although, while I chose the advanced export options on my first site, when it came to the saferhomes domain I forgot them and it caused a sufficient headache on the other end that I actually went back and re-did the export with them selected. If you’re changing domain I don’t expect it’ll be such an issue but it certainly helped for just moving the domain to another).

With saferhomes.nz though I have an additional challenge. Under Plesk I had it using Letsencrypt to automatically get and keep an SSL certificate up-to-date. Lightsail’s WordPress has no such easy feature, and it uses a custom server setup for WordPress and Apache from Bitnami. SSL is a must on this site, so I’m currently working on getting Letsencrypt running in this new landscape. It’s a work in progress, but I’ll ether make a new post on how I succeeded (yes, I’m backing myself to crack it) once I finish.

Other than that, 2 websites running on Lightsail and accessible via IP!

Wow, that’s a lot. Stay tuned (or go look) for parts 2 and probably 3 in due course.

 

One thought on “Migrating WordPress to AWS Lightsail (and other related changes) – Part 1

  1. Hey Dan, i dont profess to understand the technicalities but its fair to say you have a great writing style. I enjoyed reading it. You have a good way of telling the story.

Leave a Reply

Your email address will not be published. Required fields are marked *