Things I Learned in Quarantine - Part 4: How to setup a WordPress blog on AWS in 10 minutes
I have a friend who called to ask me about how she could set up WordPress in AWS. She had been looking at AWS Lightsail, an "an easy-to-use cloud platform that offers you everything needed to build an application or website", but she was confused about how to go about doing this and wasn't sure this was the right approach since there were so many AWS products to choose from. And she didn't want to get into the weeds into how to use AWS, she just knew that she wanted a blog running on AWS. I told her I would write up an easy tutorial for her to follow to get it done.
Originally I had planned to take last weeks article - Things I Learned in Quarantine - Setting up a (free) AWS PHP Multi-Server+Load Balanced+Auto Scaling+Continuous Delivery website in 30 minutes - and modify it to add in the database piece I touched on, but then I came across something that was much easier.
I found this helpful article from Amazon titled Tutorial: Hosting a WordPress Blog with Amazon Linux - which covers a manual and an automated way to deploy a WordPress blog environment on AWS using a LAMP stack on an EC2 instance.
Using this as a guide there are two approaches you could take:
1) You can follow the manual process to deploy a solution with a customized LAMP stack and then use the second script to install WordPress (you need to name your stack Automation-LAMPStack-AL2),
2) You can use the automated process to deploy the entire site in 10 minutes.
This article is how to deploy an AWS WordPress blog in 10 minutes, so we are going to use the entirely automated process to show you how to get your WordPress blog up and running with virtually no effort.
STEP 1 - SETUP YOUR LAMP STACK AND INSTALL WP
1) Login in to your AWS Administrator account
2) Click on this link - AWSDocs-HostingAWordPressBlog-AL2 and you will be redirected to the same document, but in your region.
3) You can read this, but you are here to click on [Execute Automation]
4) You will see this page:
Leave the default "Simple execution" checked and click on [Execute] on the lower right corner.
And away it goes!
The automation script will execute an AWS CloudFormation (Infrastructure as Code) script to build out your LAMP stack, create a database and install WordPress. In the very first step you will see an error, do not be concerned, this is just saying that the LAMP stack has not been found and it will create it.
The first step fails because the instance Automation-LAMPStack-AL2 is not installed, so it will create the LAMP stack automatically for you. This will take a few minutes. When it's done, it will look like this:
8 minutes!
STEP 2 - SETUP WORDPRESS
In the output shown above, click on the link for Step ID #3 - outputPublicDNS and you will get a page like this
Under Output you want to grab the URL to your new WordPress site. Copy that and paste it into your browser and you're ready to setup your new WordPress site. You would then use this Output URL as your CNAME record for the domain you want to point to your WordPress installation.
That's it! You're up and running in about 10 minutes with a fresh install of WordPress on an AWS LAMP stack! Pick your language and then configure your site.
Click [Install WordPress] and it's done, you can now long into your console.
If you want to see your LAMP stack and its configuration, you can go to your EC2 Dashboard and under Instances you'll find Automation-LAMPStack-AL2 and you can click on it to look for the information you want. You will notice it is running on an Instance Type of t2.small.
If you decide to modify the configuration to add Load Balancing and/or Auto Scaling, you'll need to run the script again to reinstall WordPress in your new instance since this one will be deleted (as will your data, unless you back it up). This is a great way to get started with WordPress and get everything setup and designed before you back it up, customize the infrastructure and then restore your database.
If you want to terminate/delete this instance, go to the AWS CloudFormation console, check the circle next to "LAMPStack-AL2" and click [Delete] and your LAMP stack and database will be removed.
I hope you enjoyed this article and if you have any questions or comments, please don't hesitate to post below.