Home

Three Tier Web Application

By Sotee Loey on Mar 21, 2024
Image post 5

In this AWS project, I configure and deploy phpMyadmin web application in a Three Tier architecture. The architecture of the project consists of the web tier (ALB), the application tier (php), and the database tier(MySQL RDS).

Network Architecture Consists of:

  • A VPC.
  • Two public subnets in two availability zones (Web Tier).
  • Two private subnets in two availability zones (Application Tier).
  • Two private subnets spread in two availability zones (Database Tier).
  • Three route tables:
    1. public web route table that connects the public subnets to an internet gateway.
    2. private application route table that connect the Application Tier private subnets and a NAT gateway.
    3. private database route table that connect the Database Tier private subnets and a NAT gateway.
  • An Internet Gateway connects an AWS VPC to the Internet.
  • A NAT Gateway connects private subnets.

Network Project Steps:

  1. Create a VPC
    • Go to AWS Concolse > VPC > Click Create VPC.
    • Give VPC a name and click Create VPC.
  2. Create Subnets
    • Go to VPC > Subnets > Click Create Subnets.
    • For VPC ID, Select the VPC created early.
    • Create two public web subnets in two AZ.
    • Create two private application subnets in two AZ.
    • Create two private database subnets in two AZ.
  3. Create Route tables
    • Go t0 VPC > Route tables > Click Create route table
    • For VPC ID, Select the VPC created early.
    • Create a public web, a private application and a private database route tables.
    • Map route table to subnets.
  4. Create an Internet Gateway.
  5. Create a NAT Gateway.
    • For Subnets choose web public subnets.
  6. Add a route destination 0.0.0.0/0 in public web subnets and point to Internet Gateway.
  7. Add a route destination 0.0.0.0/0 in private application subnets and point to NAT Gateway.
  8. Add a route destination 0.0.0.0/0 in private database subnets and point to NAT Gateway.

Web and Application Tier Project Steps:

  1. Create jump server EC2 instance
    • Go to EC2 > Instances > Click on Launch instances
    • Give instance a name for a jump server instance
    • Select Amazon Linux 2023 AMI and t2.micro free tier
    • Click Create new key pair and download to desktop/laptop
    • Select VPC created earlier and public web subnet
    • Enable public IP
    • Create new security group for jump server security group
    • Keep the rest as default
    • Click Launch instances
  2. Create two private php server EC2 instances
    • Give instance a name for a private PHP server instance
    • Select Amazon Linux 2023 AMI and t2.micro free tier
    • Disable public IP
    • Create new php server security group
    • Click Launch instances
  3. Create Application Load Balancing (ALB)
    • Create ALB Security Group.
    • Create Target Group.
    • Create Target Group Security Group.
  4. Use SSH Client to connect to jump server
    • One login to jump server, Connect to private PHP sever.
    • Follow instruction to install Apache Sever and phpMyAdmin in both private PHP servers.
  5. Go back to Load Balancing > Target Groups
    • Add the two private PHP servers to Target Groups.
    • Make sure the instances in healthy state

Database Tier Project Steps:

  1. Create DB Subnet groups
    • Go to Amazon RDS > Subnet groups.
    • Give DB Subnet a name.
    • Choose two available zones.
    • Select the two subnet that we created for the database.
  2. Create DB instance
    • Go to Database, click on Create database.
    • Give DB instance indentifier a name.
    • Inpute password and confirm.
    • Create new DB security group.
  3. Allow PHP server to connect to DB instance
    • Add Custom TCP and port 3306 in DB security group for PHP sever security group.
  4. Modify the config file in PHP server to point to DB end point
    • Use SSH client to login to PHP server.
    • Go to phpMyAdmin folder.
    • Edit the file config.inc.php.
    • Under Authentication section, change localhost to a DB end point.
  5. Enable Stickiness session due to phpMyadmin is statefull apllication
    • Go EC2 > Target group select the target group
    • Select Attributes tab > Select Edit and enable Stickiness session
Subscribe to my Newsletters

Stay up-to-date with new posts