Deploy WordPress with Amazon RDS
Module 2
Module 2: Creating an EC2 Instance
In this module, you will create an Amazon EC2 instance to run your WordPress site
Overview
In this module, you will create an Amazon EC2 instance to run your WordPress site. Amazon EC2 provides highly configurable server instances on-demand. On an EC2 instance, you can run a WordPress site that will be accessible by users anywhere.
What you will accomplish
Time to complete
10 minutes
Services used
Why use Amazon EC2 for your WordPress site?
When getting started with WordPress, you may test it out by installing and running it on your laptop or desktop. This is fine for a test, but you will quickly hit its limitations. Your WordPress site will only be running as long as your laptop or desktop is running. Further, the site will only be accessible by you—it won’t be available over the public internet.
A better approach is to use a server.
Amazon EC2 provides on-demand server provisioning. With Amazon EC2, you rent out server instances with varying sizes, each with different CPU, RAM, and network configuration. You pay by the hour for these servers, and you can use them to host websites, like your WordPress site. With an EC2 instance, your WordPress site will remain up and running and will be accessible by anyone over the internet.
In the steps below, you will launch an EC2 instance to host your WordPress site.
Implementation
-
Choosing an Amazon Machine Image
a. To create your EC2 instance, go to Amazon EC2 in the AWS Management Console. Choose the Launch instance button to open the instance creation wizard.
b. On the first page, enter wordpress app as your instance name.
c. Next, choose an Amazon Machine Image (AMI). The AMI you choose will determine the base software that is installed on your new EC2 instance. This includes the operating system (Amazon Linux, Red Hat Enterprise Linux, Ubuntu, Microsoft Server, etc.), and the applications that are installed on the machine.
Many AMIs are general-purpose AMIs for running many different applications, but some are purpose-built for specific use cases, such as the Deep Learning AMI or various AWS Marketplace AMIs.
For this tutorial, choose the Amazon Linux 2 AMI (HVM) in the AMI selection view.NOTE: Some commands in this tutorial will not work if Amazon Linux 2023 is selected.
-
Choosing an instance type
Scroll down to select an EC2 instance type. An instance type is a particular configuration of CPU, memory (RAM), storage, and network capacity.
AWS has a huge selection of instance types that cover many different workloads. Some are geared toward memory-intensive workloads, such as databases and caches, while others are aimed at compute-heavy workloads, such as image processing or video encoding.
Amazon EC2 allows you to run 750 hours per month of a t2.micro instance under the AWS Free Tier. Select this option for this guide so that you won’t incur any costs on your bill.a. Select the t2.micro instance. -
Configuring an SSH key
You will see a details page on how to configure a key pair for your instance. You will use the key pair to SSH into your instance, which will give you the ability to run commands on your server.
a. Open the key pair (login) section and choose Create new key pair for your instance.
b. Give your key pair a name. Then choose the Create key pair button, which will download the .pem file to your machine. You will use this file in the next module. -
Configuring a security group and launching your instance
You need to configure a security group before launching your instance. Security groups are networking rules that describe the kind of network traffic that is allowed to your EC2 instance. You want to allow two kinds of traffic to your instance:
- SSH traffic from your current IP address so you can use the SSH protocol to log in to your EC2 instance and configure WordPress
- HTTP traffic from all IP addresses so that users can view your WordPress site.
a. To configure this, select Allow SSH traffic from My IP and select Allow HTTP traffic from the internet.b. In the Network settings section, choose the Edit button. Scroll down to Firewall (security groups) and enter wordpress for the Security group name.
-
Launch
It is now time to launch your EC2 instance.
a. Choose the Launch instance button to create your EC2 instance.
You have successfully launched your EC2 instance. In the next module, we will configure your Amazon RDS database to work with your EC2 instance.