Building a Multi-Tier WordPress Site

Project 4

My goal in this project is to create a WordPress site backed by multiple of AWS services: EC2, RDS, Auto Scaling Group (ASG), and Application Load Balancer (ALB). Let’s see how it goes. 

VPC

At certain points in the guide, you will find references to corresponding images at the end of a sentence. Each image has a title at the bottom when you click on it.

Create the VPC and make sure it has the full 10.0.0.0/16 CIDR range.

I have to make a couple of subnets. A private one and a public one.

I go ahead and make these two subnets. To make a subnet public, we have to enable “auto-assign public IP”.

Then, I create an Internet Gateway so instances inside this subnet can access the internet.

Another requirement for VPC to function, is to set up routing tables. Other things such as Network ACLs or endpoints can be set up later.

Problem

My VPC was made with “10.0.0.0/24” CIDR range, and when I went to create multiple subnets, they were always overlapping no matter what

 

Solution

  • “/24” only allows a total of 256 IP. From 10.0.0.0 – 10.0.0.256
  • The CIDR of the VPC needs to be expanded because all 256 IP are overlapping.
  • I fixed this in step 1

RDS

Here I add in details for my RDS Database

Problem

I created a private subnet in my VPC dedicated for my RDS database, however, when I try to select subnet group, the subnet does not appear, and when I select the “create db subnet group” option, the UI tells me I need to have two subnets dedicated for my RDS.

Solution

  • I went to search up “aws rds in vpc”. AWS then provides me a page where it explains setting up RDS in a vpc and everything about subnet groups.
  • Subnet groups are different from a regular subnet. [Step 2 – DatabaseVPC issue (3-4) ]
  • Once I realized that a subnet group is made of multiple private subnets, I created another private subnet [Step 2 – DatabaseVPC issue (5-6) ]
  • Then, I went to the RDS management console, and found “Subnet Groups,” where I was able to create the subnet group. [Step 2 – DatabaseVPC issue (7-8) ]

EC2

First, I have to choose an instance AMI. I read of a good instance AMI for WordPress that I will run with for this setup. (EC2 instance 1-2)

Fill in details for my VPC. (EC2 instance 3)

One more important thing is my security group, which I will modify later. (EC2 instance 4)

SSH into this instance

Install httpd, start it, and enable it. Httpd will help me serve content to the web. (Setting up EC2 1-2)

Inside the /var/www/html directory I stuck a file with a message in it to display on the internet (Setting up EC2 3-4)

Next, we have to install php, probably because WordPress runs with PHP code. (Setting up EC2 5-9)

WordPress is now ready to come into play. So, I install a wordpress package that, currently, is compressed and needs to be opened using the ‘tar’ command. (Setting up EC2 10-12)

 

 

Renaming the folder and one of the files (Setting up EC2 13-14)

And, finally, fill in the details to connect my RDS database to WordPress. (Setting up EC2 15)

Configuring VPC

Setting up NACLs for Public and Private subnets. The public subnet, I believe, will need an ephemeral port, while the private subnet will receive traffic coming from the public subnet.

Solving PHP Issue

Problem

I have an old PHP version installed that WordPress doesn’t support

First, I install the repository. This is basically a place where I can find the packages I need to download. (Installing PHP 2)

Then I install a package manager. (Installing PHP 3)

My packages are not installing for some reason. (Installing PHP 4)

After some research, I found a solution that points me to a file I need modify in /etc/yum/pluginconf.d/priorities.conf. (Installing PHP 5-7)

Once I disable this file, the packages download just fine. (Installing PHP 8)

All done (Installing PHP 9)

Solving Server Issue

Once I finish updating PHP, I get a connection error message. (Solving Server Issue 1)

I figured it out. The file I disabled previously, when updating PHP, needs to be re-enabled. (Solving Server Issue 2-3)

Solving Database Connection Issue

When trying to connect to WordPress, I get a Database Connection issue. Not bad! Usually the connection error issues are the most tricky to fix. (Solving Database Connection Issue 1)

 

It probably signifies I need to head over to the security groups or the Network ACLs section. In this case, I forgot to organize my security group. (Solving Database Connection Issue 2-3)

Now it works (Solving Database Connection Issue 4)

Logging into WordPress

Filling in some details and logging into WordPress