How to host an WordPress on AWS in 5 mins.

Yu Che Liu
4 min readJan 26, 2021

WordPress is a popular content management system. The system written in PHP and use MySQL as their database. AWS is one of the biggest cloud industry provider. In this post, you will learn how to combine these two amazing tool together.

To host WordPress, we need a server and database. In this example, we are going to create a EC2 instance for our server and Aurora MySQL for the database service.

Photo by Stephen Phillips - Hostreviews.co.uk on Unsplash

In this post, you will follow the step below:

  1. Create two Security Groups, one is Web-DMZ and another one is RDS-launch, under default VPC.
  2. Create a role to allow EC2 instance to have access to S3.
  3. Create an EC2 instance under Web-DMZ Security Group, and assign role to allow EC2 have access to S3.
  4. Create an Aurora MySQL database under RDS-launch Security Group
  5. Set the inbound rule for Web-DMZ and RDS-launch
  6. Remote access, SSH, to EC2 instance
  7. install the WordPress on EC2 instance.
  8. get the public IP address to start configure WordPress.

Let start:

  1. Create two Security Groups, one is Web-DMZ and another one is RDS-launch, under default VPC.

Enter VPC and search the Security Group on the left hand side.

After create two Security Groups, we will get the result like below:

Web-DMZ
RDS-launch

2. Create a role to allow EC2 instance to have access to S3.

Go to IAM session, and click the Roles on the left hand side.

click create role button, and select EC2 instance.

give the S3FullAccess to the EC2 instance role.

We will get the result like

3. Create an EC2 instance under Web-DMZ Security Group, and assign role to allow EC2 have access to S3.

Create an EC2 instance for hosting our WordPress. Pease select the Web-DMZ security group, and select the IAM role to let EC2 instance can access to S3.

4. Create an Aurora MySQL database under RDS-launch Security Group

Go to RDS session, and click create new RDS database.

select Dev/Test to avoid huge cost. select the username and password.

Choose the small instance type.

Allow the RDS to have another database copy ready on the side to deal with the failure for Main database.

Select the Security Group that we create for RDS.

Remember to give the name for the database, we will use this one for the EC2 to access the database.

5. Set the inbound rule for Web-DMZ and RDS-launch

Web-DMZ needs three inbound rules: HTTPS(443), HTTP(80), SSH(22)
RDS-launch needs one inbound rule: MYSQL(Aurora):3306

6. Remote access, SSH, to EC2 instance

In the terminal, type “ssh ec2-user@<your ip address> -i <your pem file>”

7. install the WordPress on EC2 instance.

Type the following command:

yum update -y

yum install httpd php php-mysql -y

cd /var/www/html

wget https://wordpress.org/wordpress-5.1.1.tar.gz

tar -xzf wordpress-5.1.1.tar.gz

cp -r wordpress/* /var/www/html/

8. get the public IP address to start configure WordPress.

Grab the IP address of your EC2 instance, and paste on the browser.

WordPress

Now, you can start to setting up your WordPress.

Photo by Eilis Garvey on Unsplash

I hope you guys can enjoy this post, if you have any question please leave your comment or message me on Linkedin: Liu Yu Che | LinkedIn.

--

--

Yu Che Liu

Java Full stack developer | Google Android Associate developer certified | CompTIA Linux + certified | Teaching Assistant | https://www.linkedin.com/in/yucheliu