Migrating Our WordPress Site To AWS Lightsail In A Few Steps

Share This Post

Lightsail Logo

The growth of SoBros has been enormous over the past year or so. Great news for this website, but we had outgrown our shared hosting service and we were going over our usage limits almost daily. After some research, I found that Amazon Lightsail would be the best solution for this website. After a few minor hiccups, this has been a major success.

First off, let me state a little bit about my background. I’m a Software Engineer for a major media company. I support one of the top 2000 websites by traffic on the entire internet. I have six years experience writing server side code, but WordPress and moving a website were things I did not have experience with. After working with WordPress, it’s a platform that I would recommend to almost anyone. The community support, free plugins available, and ease of use make it an ideal platform for almost anyone. To put it simply, I have enjoyed using WordPress.

I would like to give a shoutout to Adrian Milne for writing this guide on how to migrate your WordPress site. It was very useful and helped get me started on this process. We had made a trial run of this a week before the actual migration. All went well that time. When we started doing the actual migration, I kept getting errors about S3 uploads. After beating my head against a wall, I realized that both the old server and the new server needed their local backups deleted. Since the SoBros site is about 7GB in all, it was easy to run out of room on a 20GB hard drive. After these backups were clear, the updraft plus backup and restore process went great. One thing I do recommend, is that at every success point you should make a snapshot that you can restore from. I can tear down and restore from a snapshot in minutes. Another thing I recommend is using a static IP.

For you AWS Nerds out there, I’m sure you might be asking, “Why didn’t you put the website on EC2?” Well – a few reasons. First off, I’m one of two technically capable people of running this website. The other guy doesn’t have any AWS experience (No offense Ralph Wiggum, you’ll get there). Lightsail makes it extremely easy to understand servers, load balancers, IP address, snapshots and so on. It’s so easy that a non-technical person could become a Lightsail master in almost no time. If I were to get ran over by a truck, and this website were on EC2, they would be screwed. Not to mention, Lightsail is actually slightly cheaper for the same performance. A t2-nano and our Lightsail instance are about the same sizes, but the Lightsail instance offers better performance.

During this process, we moved our domain to AWS Route 53. I had no experience doing this. The process took about one week to complete in total. When we switched our name servers over to the new LightSail instance, I didn’t realize that I should have lowered the TTL on the name servers first, then I should have changed them. That would have saved me a lot of headache and trouble. But after about 24 hours, all seemed to go fine. Just remember, when switching name servers to lower your TTL to an hour or less, wait two days for cache to clear at the DNS level, then switch your name servers.

One thing I didn’t realize that needed to be done is installing an SSL certificate. This is important now, but will be more and more important as people take major SEO hits for non-secure sites and mixed content. I followed this guide from Bitnami. I did ignore one command though since the file didn’t exist and that command was: ‘sudo mv /opt/bitnami/apache2/conf/server.csr /opt/bitnami/apache2/conf/server.csr.old’ I went ahead and setup the script and crontab to automatically renew the certificate and I highly recommend you do the same. This will save you a lot of trouble three months from now when the certificate expires.

After finally getting the website up and running. I wanted to solve three problems I noticed. One is that our images were taking about about 90% of our 7GB hard drive usage. The second is I noticed mixed content on the website due to images not coming over HTTPS. The third is we didn’t have a CDN for our images. That’s when I found a guide on how to move your images to s3. This was somewhat tricky and I recommend you SSH into the server and regenerate the thumbnails there. Install the AWS CLI using this guide. Then set your AWS credentials using this guide. Once this is done, you should be able to regenerate your images using the commands stated here.

Moving our images to S3 solved the https problem and the hard drive usage problem. What about the CDN? Here comes Amazon Cloudfront. By the way, if you do move your images to S3, I highly recommend that you use Cloudfront as well. Costs are much cheaper with Cloudfront than S3, plus your website will perform better. (Reddit user marazanvose corrected me on this, it’s slightly more expensive for CloudFront) The guide on how to setup cloudfront is here. After you have this setup, you’ll come back to your Offload S3 Lite command and change the Cloudfront or custom domain option to on and put your Cloudfront URL there.

As if doing all that wasn’t enough, I decided to take a stab at making an Alexa app using this guide. It took me about 30 minutes to install that and submit it. A good 25 minutes of that was spent making the images the correct dimensions. Everyone on the SoBros staff seemed impressed, little do they know how easy it is to create an Alexa Skill. I plan on circling back to this and adding a briefing skill as well.

As a backend developer, I learned a great deal about moving domains, nameservers, IPs, and SSL. I learned how great the WordPress platform is. There is no excuse for your website to look like it came out of 1994 with WordPress. It’s a great platform that most sites on the internet can utilize. This website can handle an enormous amount of traffic on a $5/mo Lightsail instance, Free-Tier S3, and Free-Tier Cloudfront. Once the free-tier is up after 12 months, it will still be less than $1 additional to run it. Now this website can continue to grow in content and in traffic with almost unlimited potential. If you have any questions, feel free to reach out on Twitter.

Update: Almost two years later and the Lightsail solution has held up well. We’ve had to scale it up several times, but it usually on takes a few minutes to do so. We’ve also been able to set up a dev environment to test site changes side by side with production. I highly recommend moving to AWS Lightsail if you haven’t done so yet.

Update: As for Sept 8th, 2021 we are still running this setup. I moved us out of s3 for our images and attached a larged hard drive to our servers. The site runs really fast still.

Smokey covers the Tennessee Volunteers for the SoBros Network. He loves a good backpacking trip, but hates taking a shit in the woods. Follow on Twitter: @SoBroSmokey

Buy our shirt. Like us on Facebook. Follow us on Twitter @SoBrosNetwork. Listen on SoundCloud. Watch on YouTube. Shop our store on Redbubble.

Subscribe To Our Newsletter

Get updates and learn from the best

More To Explore