This is a diagram that I have used for the lab.

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 on Multi-AZ deployments.
- Create an AMI image for the WordPress instance.
- Create a Launch configuration
- Set up an Auto Scaling Group with your launch configuration
- Create a CNAME record on your DNS zone for the Amazon domain name
- Test an Application Load Balancer for WordPress on multiple AZs with MySQL instance on Multi-AZ deployments
Create a new VPC with CIDR 10.0.0.0/16
Create 4 private subnets: 10.0.0.0/24 on us-east-1a and 10.0.1.0/24 on us-east-1b, 10.0.2.0/24 on us-east-1c, and 10.0.3.0/24 on us-east-1d.

Launches a new Linux instance to run WordPress on AZ1.

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
On Security Group, allow SSH, HTTP, HTTPS, and MySQL/Audora from 0.0.0.0/0.

SSH to Linux instance.
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
Copy all files on WordPress directory to /var/www/html.
cd wordpress
sudo cp -r * /var/www/html
cd /var/www/html

Create an ip.php file on /var/www/html directory.
#sudo nano ip.php
<?php
echo "Local IP address: "; echo $_SERVER['SERVER_ADDR'];
echo "<br>";
echo "Public IP address: "; echo $_SERVER['SERVER_NAME']
?>
Create a new AutoScaling-Security-Group-1 Security Group.

Go to Amazon RDS, and create subnet groups.

Then create a database.
Choose MYSQL, and choose the Dev/Test option and Multi-AZ DB instance Deployments.

Enter wordpress on the database/user/password setting. Then, select “Burstable classes” as following screenshot.


Unselect “Enable storage autoscaling” in this lab.

Security Group is AutoScaling-Security-Group.

Enter wordpress on the initial database name and uncheck “Enable Automatic backups”.

Then click “create database”.



MySQL instance has been successfully deployed on both Availability zones.

Set up WordPress on Linux instance. Copy the public IP address of the Linux instance and paste it into your web browser (http://44.203.24.125).

Copy RDS information that we have configured in previous steps.
The database host is an RDS instance on multiple AZs.

Create a new wp-config.php file under the/var/www/html directory and copy and paste the information in the screenshot below to this file.

Login to WP.

Check local and public IP addresses of WP instance (http://44.203.24.125/ip.php)

Check the IP address of the MySQL RDS instance.

Now, we move on to create an image for this WordPress instance. Click Actions – Image and templates – Create image.



Next, we create a “Launch configuration” with this image.

Click “Advanced details” and select “Assign a public IP address to every instance”

Choose Security group, and click create launch configuration.


Now, go to create the “Auto Scaling group” for the WP instance.


Select attach to a new load balancer.



Desired capacity: 2
Minimum capacity: 1
Maximum capacity: 4

Create “Auto Scaling Group”


On Load Balancer, copy the DNS name of ALB load balancer.


On Target group.


Go to instances, it can be seen that new both WP instances have been automatically created via AutoScaling group.



Go to your DNS zone setting on GoDaddy, add Amazon domain name as a CNAME record on your DNS zone as a screenshot below.


Check first WP instance.

Second WP instance.


Go to alb.tungle.ca. It can be seen that WordPress Application Load Balancing has been successfully deployed on AWS


We can see that both WP has accessed the master MySQL RDS.

Terminated a WP instance, then the new WP instance will be immediately created on AWS.


There is no downtime when terminating the WP instance.


Edit the Security Group, then only allows AutoScalling-Security-SG group on accessing MySQL instance on WordPress-SG security group.
