Implement WordPress load balancing with Multi-AZs deployment for Amazon RDS on AWS

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

Create 4 private subnets: on us-east-1a and on us-east-1b, on us-east-1c, and on us-east-1d.

Launches a new Linux instance to run WordPress on AZ1.

Copy it into the User data setting.

yum update -y
# Install Apache web service
yum install httpd -y
# Download WordPress 
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

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
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 (

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 (

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 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.