Build a Lightning Fast WordPress Website on AWS: Simple Single Server Setup
The articles that make up this collection are as follows.
1. Build a Lightning Fast WordPress Website on AWS – Introduction
2. Build a Lightning Fast WordPress Website on AWS – Simple Single Server Setup (this article)
3. Build a Lightning Fast WordPress Website on AWS – Route 53
3. Build a Lightning Fast WordPress Website on AWS – EC2
4. Build a Lightning Fast WordPress Website on AWS – S3 and CloudFront
5. Build a Lightning Fast WordPress Website on AWS – EC2 Fault Tolerant, Durable and Scalable
6. Build a Lightning Fast WordPress Website on AWS – EC2 Administration
7. Build a Lightning Fast WordPress Website on AWS – DynamoDB
8. Build a Lightning Fast WordPress Website on AWS – API Gateway
The Plan for this guide
1. Sign Up to AWS.
2. Select a Region.
3. Navigate to the EC2 dash.
4. Chose an AMI.
5. Prepare for Launch.
6. Choose an Instance Type.
7. Review and Launch.
8. Get Connected.
9. Remove the Bitnami icon.
10. Add some content.
11. Other stuff.
The Plan for this article.
Is to make a new WordPress site hosted on AWS as quickly and simply as possible. The infrastructure created in this guide will be used in subsequent steps, which altogether will produce a production ready system as described in the previous article. The idea is that along the way you learn a little about each AWS service or resource that we use. It’s oriented around AWS learning, and a by-product of following these actions, is the creation of a highly available, low latency, scalable and production ready website for any sized business.
Sign Up to AWS
I’m not going to cover signing up to AWS. It’s no different to any other website. There are a lot of best practices when it comes to generating yourself an account, especially if it is a business account and you have multiple users. AWS lets you assign permissions to groups and then individual users all connected to your account can be added as members of those groups to inherit the privileges. There will be more detail on this later, but for now, to keep things simple just sign up. AWS will make you the “root” user. The root user can perform all actions on an account, and provision anything they like without restriction (within pre-defined AWS limits). You may complete this step as the root user, this will be default once you have signed up and logged in anyway.
New Term : Root User
Any new terms I use, I will highlight in these boxes.
A Root user is the main user associated with an AWS account. The Root user has unrestricted access and can perform all actions on that account.
Select a Region
AWS is made up from a series of data centres that are distributed around the planet (At the time of writing there are 12, but Amazon keep adding more). This is something we can make use of, as we can place resources close to our users to give them a lower latency. There is no point sending traffic across an ocean and back when we don’t have to. This will be covered in more detail later, but for the purpose of this setup; select the region closest to where your user will be based. I live in Sheffield in the UK.
The closest two regions for me are Dublin (eu-west-1) and London (eu-west-2). Dublin is around 230km from Sheffield, London is around 230km from Sheffield. I am running a UK website, my users will most likely be weighted towards London as more people live there, so I’ll select London.
New Term : Region
A geographically distinct location on AWS.
Regions are completely independent of one another.
Navigate to the EC2 dash
Once you are logged in. At the top left of the site next to the AWS logo. Click the “Services” link. The AWS Console will appear. This is a big panel full of all the different resources and services you can provision on AWS. It’s a big list, and it keeps growing.
Click the EC2 link and you will be transferred over to the EC2 dash. EC2 is an abbreviation for Elastic Cloud Compute (one E, two C’s … EC2). A simpler title would be “Servers” which is essentially what EC2 is. However, the word “Elastic” you will see on many of the AWS services. Elastic means it is a resource or service that can scale. It doesn’t mean it will scale out of the box, you may need to configure it to scale, in this article we won’t be making anything that scales, but we still need to launch a server, and that is done via the EC2 dash.
New Term : EC2
Elastic Cloud Compute.
Amazon Elastic Compute Cloud (Amazon EC2) provides scalable computing capacity in the Amazon Web Services (AWS) cloud. Using Amazon EC2 eliminates your need to invest in hardware up front, so you can develop and deploy applications faster. You can use Amazon EC2 to launch as many or as few virtual servers as you need, configure security and networking, and manage storage. Amazon EC2 enables you to scale up or down to handle changes in requirements or spikes in popularity, reducing your need to forecast traffic.
Prepare for Launch
“Launch” is a word to note. On AWS if you need more resources for your applications, you launch them. Amazon are selling us infrastructure as a service (IaaS). With IaaS you fill in a form to identify specifically which resource you require, you check the pricing structure for that resource and then you launch it. What happens once you click launch is nothing you need to worry about, that’s AWS’ job, that’s what you pay them for (eventually). They work out technically how to deliver you a machine or a slice of a machine for you to use exclusively. The resources we will be launching in this step fall under the AWS free tier, meaning you won’t pay for them as a new user.
Click the big blue button from the EC2 dash, labelled “Launch Instance”
New Term : Iaas
Infrastructure as a Service
Infrastructure as a Service, sometimes abbreviated as IaaS, contains the basic building blocks for cloud IT and typically provide access to networking features, computers (virtual or on dedicated hardware), and data storage space. Infrastructure as a Service provides you with the highest level of flexibility and management control over your IT resources and is most similar to existing IT resources that many IT departments and developers are familiar with today.
Chose an AMI
We can take our time configuring a new server to get WordPress up and running. A Linux based OS would be simple. Off the top of my head, we would need to:
– install any updates to the OS (Ubuntu, Red hat or whatever)
– install the latest PHP release
– install the latest MySql release
– install the latest Apache release
– configure lots of .ini and .conf files
– install the lastest WordPress release
– test it all works
– cry when it doesn’t
– discover basic noob mistakes and fix
– punch the air and enjoy the feeling of success, you managed to get a very simple CMS driven website running
If we did all this, it would take time. Over my development career I’ve lost count of the amount of times I’ve set WordPress up (not sure I’ve ever had it work first try either). Amazon provides us with a really neat set of tools for creating snapshots of pre-configured machines. On AWS these snapshots can be used to create an AMI, or Amazon Machine; that contains the OS and all installed applications. Once I’ve created the perfect WordPress box, I can use it create an AMI and then use the AMI in the future to launch as many Worpress machines as I like, without editing a single .conf file.
Maybe my WordPress AMI would be useful for others? If Amazon had an AWS marketplace I could sell it and become rich. Well it does have a marketplace for AMI’s! however, it’s already been done and a bunch of nice people known as “Bitnami” are giving away their configured WordPress AMI for free. It’s tried and tested, and it’s a much better option than configuring from scratch. You will notice we are on step 1 of 7 looking at the tabs on the top. Select “AWS Marketplace” from the sub-tabs on the left and search for “Wordpress”
The top option should be the “Wordpress Certified by Bitnami”. Select this AMI by clicking the blue button labelled “Select” on the right of the screen.
New Term : AMI
Amazon Machine Image
An Amazon Machine Image (AMI) is a special type of virtual appliance that is used to create a virtual machine within the Amazon Elastic Compute Cloud (“EC2”). It serves as the basic unit of deployment for services delivered using EC2.
Choose an Instance Type
You will now be asked to select which type of EC2 instance you wish to launch. Amazon have an array of different machine types that we can launch at will. Which machine type we need depends entirely on the purpose and expected load of our application. Different instance types come loaded with different CPU’s, different amounts of RAM and storage. By default a t2.micro instance type will be selected. This instance type doesn’t come with much hardware power, but is perfect for development or experimentation … or this guide. There is a smaller, less powerful instance types available, a t2.nano is smaller than a t2.micro, but as the t2.micro already falls within AWS free tier, we might as well take advantage of it.
Review and Launch
Click the blue Review and Launch button.
This will skip you on to step 7/7. You have left configuration, storage and security settings as default. For the purpose of this experiment it is fine to do so, but feel free to have a click through those steps to see what other kind of configurations and settings can be applied. Step 7/7 is Review Instance Launch. Listed are the orders we are making. Click the blue Launch button to continue.
A dialog will appear asking you which key pair you would like to use. A key pair is a file containing credentials that you can specify when connecting directly to an EC2 instance. Let’s say we wanted to patch the OS of an EC2 instance. The simplest way to do this would be via SSH, providing the key pair as the connection credentials to give use authority to access the server. As we are using an AMI that comes with WordPress running out of the box, which has an admin panel accessible over HTTP, we don’t need to bother with a key pair. From the first dropdown select “Proceed without a key pair option, check the box to acknowledge that we definitely know what we are doing and click the blue Launch Instances button.
New Term : Key Pair
A Key Pair consists of a public key stored on AWS and a private key, stored in a file that acts like a password to give you access to EC2 instances.
You should be presented with an animated loading gif.
Then you will be redirected to a screen entitled Launch Status.
“Your instances are now launching” should fill you with a warm feeling of hope.
AWS even provide us with a blue “View Instances” button. That’s convenient, click it.
Your instance will not be immediately available. We have to wait for one of the Amazon robots to wheel itself down the corridor and press the big red button to switch your machine on. Well, who knows what Amazon actually do … it’s nothing we need to be concerned with, this is the beauty of IaaS, it is Amazon’s responsibility to provision your resources. On the EC2 dash once your instance is running, the Instance State field will show a green light icon, and read “running”. In this screenshot I can also see Amazon are doing some Status Checks, I don’t need to wait for these. The thing I really need is the instance’s public DNS (IPv4) address. In my case this is
Copy this address and paste it into your favourite browser. If everything went to plan you should see the public facing part of your WordPress website. Et Viola.
Remove the Bitnami Icon
The little Bitnami icon in the bottom right is something we will need to remove. If you click it has a page that tells you how to do this. It instructs you to SSH onto the box and run a few simple shell commands. We can’t do that! We set the instance up without a Key Pair so we are unable to log on to the OS. However, there is always a workaround. We need to be able to logon to the admin panel and edit the running theme. Add “/wp-admin” to the public DNS address you just used to get to your WordPress home and visit this address in your browser; For me this will be …
You will see the WordPress Admin logon panel, which requires a username and password. To find that, go back to your EC2 dash. Click the “X Running Instances” link to get to your instance listing (where X represents the amount of EC2 instances you currently have up and running). Find the row that represents the instance with the DNS address you used earlier and right click anywhere on this row. Mouse over “Instance Settings” to open out the next context menu and then click “Get System Log”
This will show us a log of all the things that happened when the instance booted up. Bitnami added an output in here with your root WordPress username and password. The log is quite long, you will have to scroll through it but the part you are looking for stars with “Setting Bitnami application password to” and there you should see your password. You can also see the username is “user”
Use these credentials to login to the admin section of your WordPress system.
From the menu on the left, find the menu item labelled “Appearance” mouse over this to reveal more menu options and select “Customize”.
This takes you to the WordPress editor for the installed theme. Scroll down through the options and find “Additional CSS”. The purpose of this section is to enable you to override the style of your theme with your own custom styles.
This gives us an easy opportunity to make the Bitnami Logo vanish.
Simply paste in the following CSS:
Then click the blue “Publish” button.
Add Some Content
You now have an instance up and running, and if you are eager to write some content, then get cracking. The nest sections of this guide will ensure you keep any data you create in the mysql database. If you don’t fancy writing content yet, just add a few test articles so you can follow the next sections and have something to click and play with.