This is a diagram that I have used to deploy this lab.
![](https://tungle.ca/wp-content/uploads/2022/04/image-535.png)
There are a couple of main steps that I have used in the lab.
- Create both private subnets on both AZs
- Create a WordPress instance on the first AZ.
- Create a new MySQL instance.
- Create an AMI for the WordPress instance.
- Launches a new WordPress instance 2 on the second AZ by using your customized AMI.
- Create an Application Load Balancer for WordPress on multiple AZs
- Set up a checkhealth.html file to test the Application Load Balancing
Create a new VPC with CIDR 10.0.0.0/16
Create both private subnet, 10.0.0.0/24 on us-east-1a and 10.0.1.0/24 on us-east-1b.
![](https://tungle.ca/wp-content/uploads/2022/04/image-465.png)
![](https://tungle.ca/wp-content/uploads/2022/04/image-499-1024x561.png)
Create a new Internet Gateway and attach this to your VPC.
![](https://tungle.ca/wp-content/uploads/2022/04/image-463.png)
Add a static route 0.0.0.0/0 on your Internet gateway.
![](https://tungle.ca/wp-content/uploads/2022/04/image-464-1024x388.png)
Launches a new Linux instance to run WordPress on AZ1.
![](https://tungle.ca/wp-content/uploads/2022/04/image-466.png)
Copy it into the User data setting.
#!/bin/bash
yum update -y
# Install Apache web service
yum install httpd -y
# Download WordPress
wget https://wordpress.org/latest.tar.gz
tar -zxf latest.tar.gz
# Install php7.4
amazon-linux-extras install php7.4 -y
![](https://tungle.ca/wp-content/uploads/2022/04/image-467.png)
On Security Group, allow SSH, HTTP, HTTPS, and MySQL/Audora from 0.0.0.0/0.
![](https://tungle.ca/wp-content/uploads/2022/04/image-469-1024x477.png)
![](https://tungle.ca/wp-content/uploads/2022/04/image-468-1024x458.png)
![](https://tungle.ca/wp-content/uploads/2022/04/image-470-1024x657.png)
SSH to Linux instance.
![](https://tungle.ca/wp-content/uploads/2022/04/image-471-1024x697.png)
Check httpd, php is installed on the machine.
rpm -qa | grep httpd
rpm -qa | grep php
sudo yum install php -y
sudo systemctl start httpd
sudo systemctl enable httpd
netstat -antp
![](https://tungle.ca/wp-content/uploads/2022/04/image-473.png)
Copy all files on WordPress directory to /var/www/html
cd /wordpress
sudo cp -r * /var/www/html
![](https://tungle.ca/wp-content/uploads/2022/04/image-472.png)
Go to Amazon RDS, create subnet groups on Amazon RDS.
![](https://tungle.ca/wp-content/uploads/2022/04/image-536.png)
![](https://tungle.ca/wp-content/uploads/2022/04/image-534-1024x446.png)
Create a new Database instance on AWS.
![](https://tungle.ca/wp-content/uploads/2022/04/image-474.png)
Choose the Free tier.
Enter wordpress on “DB instance identifier”, “master user name and password”
![](https://tungle.ca/wp-content/uploads/2022/04/image-475.png)
![](https://tungle.ca/wp-content/uploads/2022/04/image-476.png)
Public access is No.
![](https://tungle.ca/wp-content/uploads/2022/04/image-537.png)
Choose the Availability zone as the following screenshot.
![](https://tungle.ca/wp-content/uploads/2022/04/image-533.png)
Enter “wordpress” on the initial database name.
![](https://tungle.ca/wp-content/uploads/2022/04/image-479.png)
Backup retiontion period: 0, then click “Create database”.
![](https://tungle.ca/wp-content/uploads/2022/04/image-480.png)
Wait a couple of minutes to completely create the database instance.
![](https://tungle.ca/wp-content/uploads/2022/04/image-482-1024x520.png)
Access WordPress site via the public IP address of WP.
![](https://tungle.ca/wp-content/uploads/2022/04/image-483-1024x589.png)
Database, username, password is wordpress.
Database Host is the endpoint address of the RDS database on AWS on the previous screenshot.
Click Submit.
![](https://tungle.ca/wp-content/uploads/2022/04/image-484-1024x600.png)
Copy entire content, open SSH shell on Linux instance. Create a new wp-config.php under /var/www/html.
![](https://tungle.ca/wp-content/uploads/2022/04/image-485.png)
sudo nano wp-config.php
![](https://tungle.ca/wp-content/uploads/2022/04/image-486.png)
Back to WP web interface set up, click “Run the installation”.
![](https://tungle.ca/wp-content/uploads/2022/04/image-487.png)
![](https://tungle.ca/wp-content/uploads/2022/04/image-488.png)
Log in WP.
![](https://tungle.ca/wp-content/uploads/2022/04/image-489.png)
![](https://tungle.ca/wp-content/uploads/2022/04/image-490-1024x672.png)
Now, create a new AMI image for this WP. Right-click the WP instance, on Actions – Image and templates – Create image.
![](https://tungle.ca/wp-content/uploads/2022/04/image-491-1024x443.png)
![](https://tungle.ca/wp-content/uploads/2022/04/image-492-1024x786.png)
![](https://tungle.ca/wp-content/uploads/2022/04/image-494-1024x647.png)
Right-click AMI. Click Actions – Launch an instance from AMI.
![](https://tungle.ca/wp-content/uploads/2022/04/image-495.png)
![](https://tungle.ca/wp-content/uploads/2022/04/image-496-1024x745.png)
![](https://tungle.ca/wp-content/uploads/2022/04/image-497.png)
![](https://tungle.ca/wp-content/uploads/2022/04/image-498-1024x696.png)
Go to the load balancer, and create a new application load balancer.
![](https://tungle.ca/wp-content/uploads/2022/04/image-504.png)
![](https://tungle.ca/wp-content/uploads/2022/04/image-500.png)
![](https://tungle.ca/wp-content/uploads/2022/04/image-502.png)
Create a new WordPress ALB SG. Allow HTTP from 0.0.0.0/0 on this Security Group.
![](https://tungle.ca/wp-content/uploads/2022/04/image-503.png)
Create a target group.
Select “Instances”.
![](https://tungle.ca/wp-content/uploads/2022/04/image-505.png)
Enter “AP-ALB” on the target group name and checkhealth.html for the health check WP instance.
![](https://tungle.ca/wp-content/uploads/2022/04/image-506.png)
Change the settings as the screenshot below. Click Next.
![](https://tungle.ca/wp-content/uploads/2022/04/image-507.png)
Select both instance IDs and click “Include as pending below”.
![](https://tungle.ca/wp-content/uploads/2022/04/image-508-1024x605.png)
Create a target group.
![](https://tungle.ca/wp-content/uploads/2022/04/image-509-1024x591.png)
Back to the Application Load Balancer setup, choose the “WP-ALB” on the target group.
![](https://tungle.ca/wp-content/uploads/2022/04/image-510.png)
Create a load balancer.
![](https://tungle.ca/wp-content/uploads/2022/04/image-511.png)
![](https://tungle.ca/wp-content/uploads/2022/04/image-512-1024x653.png)
Wait a few minutes to see “Health status” is Healthy.
![](https://tungle.ca/wp-content/uploads/2022/04/image-514-1024x528.png)
SSH to Linux instance on WordPress server 2.
![](https://tungle.ca/wp-content/uploads/2022/04/image-515.png)
On WP1.
<h1> This is health check from the WordPress Server 1 </h1>
On WP server 2.
![](https://tungle.ca/wp-content/uploads/2022/04/image-516.png)
![](https://tungle.ca/wp-content/uploads/2022/04/image-517.png)
Start the httpd daemon.
sudo systemctl start httpd
![](https://tungle.ca/wp-content/uploads/2022/04/image-518.png)
![](https://tungle.ca/wp-content/uploads/2022/04/image-519.png)
Do the same on WP1 to make sure the httpd daemon is running after making the AMI template.
![](https://tungle.ca/wp-content/uploads/2022/04/image-520.png)
Access WP health check on WP server 1.
![](https://tungle.ca/wp-content/uploads/2022/04/image-521.png)
![](https://tungle.ca/wp-content/uploads/2022/04/image-532.png)
Make sure both WP servers have Healthy status on WP-ALB.
![](https://tungle.ca/wp-content/uploads/2022/04/image-522-1024x570.png)
Copy the Amazon ALB link into your web browser.
![](https://tungle.ca/wp-content/uploads/2022/04/image-523-1024x794.png)
![](https://tungle.ca/wp-content/uploads/2022/04/image-524.png)
Refresh, it can be seen that the web traffic is loaded balancing on the WP server 2.
![](https://tungle.ca/wp-content/uploads/2022/04/image-525.png)
Check the connection from WP instances to the Amazon RDS database.
![](https://tungle.ca/wp-content/uploads/2022/04/image-527.png)
I will set up Amazon Route 53, Amazon CloudFront with a real domain name such as awsbigfan.ca, and load balancing via HTTPS (WordPress SSL certificate will be issued by Amazon), not HTTP. Also. I will configure a strict Security Group policy to strengthen security from WordPress to the Amazon RSD database in the next labs.