Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Migrating My WordPress Blog to AWS Lightsail

DZone's Guide to

Migrating My WordPress Blog to AWS Lightsail

AWS Lightsail makes it simple to set up virtual private server. Follow one dev's journey to migrate his blog to Lightsail, noting the steps and benefits along the way.

· Cloud Zone
Free Resource

Site24x7 - Full stack It Infrastructure Monitoring from the cloud. Sign up for free trial.

Image title

I’ve just migrated my WordPress blog from a multisite hosting package I have with LCN to Amazon’s new Lightsail service and thought I’d just make a quick post about how the process went.

There are some more details of the why's and wherefore's for doing this, but I won't dwell on them here (more details are available on the original article on my blog). I'll just jump straight into the process I followed.

What Is AWS Lightsail?

Lightsail is basically Amazon creating a simplified (dumbed-down, whatever) product for people who want an easy way to set up a preconfigured virtual server without having to understand and navigate the myriad options available in the general AWS ecosystem (and, crucially, with predictable costs).

This simplicity is apparent throughout the Lightsail configuration UI — it's cleaner, more user-friendly, and less daunting than the full AWS console.

Behind the scenes, the Lightsail offering is a virtual machine utilizing SSD-based storage, DNS management, and a static IP address. With a few button clicks you can quickly set up favorite operating system (Amazon Linux AMI or Ubuntu), developer stack (LAMPLEMPMEAN, or Node.js), or application (DrupalJoomlaRedmineGitLab, among others), with flat-rate pricing plans that start at $5 per month for what is effectively the equivalent of an EC2 t2.nano instance.

I could have just set up the WordPress LAMP stack up on an EC2 instance — but I really just wanted simplicity for something like my blog. I have limited free time and I'd rather spend it on developing applications rather than setting up peripheral infrastructure. With Lightsail, it's just a few button clicks to configure and there is no need to worry about bandwidth (at least at my usage levels), Security Groups, Volume Sizing, etc.

Migrating My Blog

Firstly, my conclusion is that I'm really happy with the result. The process was simple, the control panel is a breeze, and I've seen a significant speed improvement over my old hosted solution — plus it's costing me less (only because I was only using 20% old my old hosting solution's capacity, though, to be fair).

Now, onto a quick recap of what I needed to do to migrate my WordPress blog to Lightsail (hardly rocket science — all straightforward and painless, but I thought it might be useful to document it nonetheless).

Step 1: Create a New Lightsail Instance

This comes after ‘Step 0 - set up an AWS account’ (I won’t go into that here — just go to AWS and setup a new account).

Firstly, log into AWS Lightsail. You will see the welcome screen showing all the instances you currently have available (in this case, there is one website I've already migrated).

Image title

Click on the 'Create Instance' button to create a new instance. There are a number of preconfigured virtual machines available — applications, development stacks, and operating systems. I just want a WordPress application set up.

Image title

Scrolling further down the Create Instance page, you have options to add launch scripts and your own SSH keys if you want to (I didn't need to do this, so just accepted the defaults).

Image title

The next step is to choose your instance plan. The cheapest, $5 plan is fine for my needs (and comes with a one month free trial at the time I'm writing this). I believe this is the equivalent of a t2.nano instance on EC2.

Image title

You have the option to change the Zone the instance runs in. Currently, the only ones available are all east coast US, so I just stuck with the default option of Virginia, Zone B.

Finally, you just need to name your instance. This is just the name that appears to you in your control panel — so I just modified the default one that was suggested.

Image title

And that's it. Your instance is created and it now appears on your dashboard.

Image title

You can navigate to your new basic WordPress instance using the public IP address that has been assigned to you.

Image title

Step 2: Connect to Your Instance

SSH via Browser

Now, to do anything useful, you need to be able to connect to your virtual server using SSH. The simplest way to do this is just to click the 'Connect using SSH' from your instance page in AWS.

Image title

This will pop up a new browser window simulating a terminal connection to the instance. It can take a minute or two after creating your instance for everything to be set up and available behind the scenes. So if you click the 'Connect using SSH' button too early, you can get the following error message.

Image title

If you wait a minute or two and try again, the SSH connection should be available.

Image title

SSH via Terminal

You can also connect via SSH from a terminal. First, you need to get your private key. You can download this from the Lightsail page for your instance. Click the 'Download default key' button.

Image title

Once downloaded, you can then add the ssh key using:

ssh-add /PATH_TO_FILE/LightsailDefaultPrivateKey.pem

And then connect using ssh:

ssh bitnami@<IPAddress>

Image title

Log into WordPress

You need to be able to connect to your instance via SSH to get the password for the WordPress user account.

Just connect via SSH and enter the command below to see your password:

cat bitnami_application_password

Image title

Once you have the password, you can then log into your WordPress site with username 'user' and the password you discovered above (using the standard login link on your WordPress site).

Image title

Migrating My Blog

I won't go into any detail on how I did the actual WordPress migration — there are a bunch of plugins available to help with this (migration and backup/restore).

I personally had been using the UpdraftPlus to take regular backups of my site and database, which it pushes directly to my DropBox account.

It was a simple matter to install the plugin on the new site, and then do a restore operation from my most recent backup files. Once I had done this (a matter of minutes) - the site was now available (still on the Public IP address only).

Image title

You'll notice that by default - there is a small Bitnami logo in the bottom right hand corner. In order to remove that - it was just a question of running the following 2 commands from SSH again:

sudo /opt/bitnami/apps/wordpress/bnconfig --disable_banner 1

sudo /opt/bitnami/ctlscript.sh restart apache


Image title

Update DNS

The final step was just to update my DNS settings for adrianmilne.com to point to the new Lightsail Public IP address, wait a few minutes, and voila, my blog was (is) now running on AWS Lightsail.

Image title

Conclusions

As I covered above, I'm very happy with the migration. It's nice to get my blog onto AWS, where I do much of my personal project work. It also works out cheaper than my previous multi-site hosting solution (only because I wasn't using it to its full potential — I like and have had very good experiences with LCN).

It's also significantly quicker. It feels snappier to use, and a basic back-of-the-fag-packet/Chrome developer tools test shows it has halved the time for a page load (or more).

Site24x7 - Full stack It Infrastructure Monitoring from the cloud. Sign up for free trial.

Topics:
wordpress ,cloud ,tutorial ,aws lightsail ,cloud migration

Published at DZone with permission of Adrian Milne, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}