Traditional 3-Tier WordPress Website Deployment on AWS

Deploying a resilient, production-grade WordPress website in the cloud requires moving beyond single-server setups. By decoupling the presentation, application, and data layers into a traditional 3-tier architecture on Amazon Web Services, organizations gain strict network isolation, horizontal scalability, and high availability across multiple Availability Zones. This comprehensive guide walks through every phase of the deployment in the US East N. Virginia region, complete with console verification screenshots.
1.1 Project Overview
A traditional 3-tier web architecture separates infrastructure responsibilities into three distinct logical layers so that public internet traffic never communicates directly with application servers or backend databases:
Presentation / Web Tier: An internet-facing Application Load Balancer deployed inside public subnets receives incoming HTTP and HTTPS requests from users and routes traffic cleanly across healthy web instances.
Application Tier: Amazon EC2 instances running Apache, PHP, and WordPress operate inside isolated private application subnets. An Amazon Elastic File System volume provides shared persistent storage for WordPress themes, plugins, and uploaded media across all instances.
Database Tier: An Amazon RDS MySQL database instance sits inside dedicated private database subnets, accepting SQL queries exclusively from the application tier security group.
1.2 Networking Setup — Create a VPC with Public and Private Subnets
The network foundation begins with creating a custom Virtual Private Cloud named my-lab-vpc and dividing its IPv4 CIDR block into dedicated public, private application, and private database subnets across multiple Availability Zones:
Public Subnets: Subnets such as PublicSubnet2 and my-lab-pubsub-1 have routes pointing to an Internet Gateway, enabling public-facing resources like the Application Load Balancer and NAT Gateway to communicate with the internet.
Private Application Subnets: Subnets such as PrivateAppSubnet2 have no direct inbound route from the Internet Gateway, shielding the WordPress web servers from external attacks.
Private Database Subnets: Subnets such as PrivateDBSubnet3 provide an isolated network enclave strictly reserved for the Amazon RDS MySQL database and EFS mount targets.
1.3 Networking Setup — Create a NAT Gateway and Security Groups
1. Provisioning the NAT Gateway
Although the WordPress EC2 instances live in private subnets without public IP addresses, they still require outbound internet access to download Linux security patches, PHP dependencies, and WordPress core packages. Deploying a public NAT Gateway inside my-lab-pubsub-1 with an allocated Elastic IP enables outbound-only internet connectivity while blocking unsolicited inbound connections.
2. Configuring Least-Privilege Security Groups
Stateful Security Groups enforce strict tier-to-tier firewall rules across the environment:
Application Load Balancer Security Group: Permits inbound HTTP on TCP port 80 and HTTPS on TCP port 443 from any IPv4 source 0.0.0.0/0, while allowing all outbound traffic.
Web/Application Tier Security Group: Accepts inbound HTTP/HTTPS traffic exclusively from the Application Load Balancer Security Group.
Database & EFS Security Groups: Restrict inbound MySQL traffic on TCP port 3306 and NFS file-system traffic on TCP port 2049 solely to the Web/Application Tier Security Group.
1.4 Database Setup — Create MySQL Database and EFS in AWS
1. Creating the RDS DB Subnet Group
Amazon RDS requires a DB Subnet Group spanning at least two Availability Zones inside the custom VPC. Creating mydbsubnetgroup groups the private database subnets so RDS can deploy and manage network interfaces securely within the isolated data tier.
2. Launching Amazon RDS for MySQL and Amazon EFS
Next, a managed Amazon RDS MySQL instance named wordpress-db is launched on a db.t3.micro instance class inside mydbsubnetgroup with public accessibility disabled and protected by sg-rds-wordpress-db. In parallel, an Amazon EFS file system is provisioned with mount targets in the private subnets so every EC2 web server mounts the exact same /var/www/html WordPress directory.
1.4 Compute & Load Balancing Setup — EC2 Instances and Application Load Balancer
Launching and Bootstrapping Private WordPress EC2 Instances
To deliver fault-tolerant compute capacity, two t3.medium EC2 instances named WordPress-Web-App-1 and WordPress-Web-App-2 were deployed inside the private application subnets across separate Availability Zones. Instead of configuring each server manually over SSH, an EC2 User Data bootstrap script automated the entire software stack installation at first boot:
Deploying the Internet-Facing Application Load Balancer
Because the EC2 web servers reside in private subnets without public IP addresses, an internet-facing Application Load Balancer named WP-ALB was provisioned across the public subnets. An HTTP listener on port 80 forwards incoming visitor requests to the target group wp-target-group, which continuously probes the private EC2 instances to verify application availability.
Once WP-ALB transitioned to the Active state and both WordPress-Web-App-1 and WordPress-Web-App-2 registered as Healthy targets, accessing the Application Load Balancer DNS endpoint in a web browser rendered the live WordPress site successfully.
1.5 Conclusion & Post-Deployment Clean-Up:
Implementing a traditional 3-tier WordPress deployment on AWS demonstrates how fundamental cloud networking and managed services work together to create secure, resilient web platforms. By isolating compute and database layers inside private subnets, enforcing least-privilege Security Group chaining, centralizing file storage on Amazon EFS, and distributing traffic through an Application Load Balancer, the architecture eliminates single points of failure while keeping sensitive backend infrastructure invisible to the public internet.
1.6 Resource Decommissioning & Cost Clean-Up Checklist:
AWS resources such as NAT Gateways, Application Load Balancers, EC2 instances, and RDS databases incur ongoing hourly charges while active. Once deployment verification is complete, resources must be terminated in reverse dependency order so network interfaces detach cleanly:
Step 1 — Delete Load Balancing & Compute Resources: Delete the Application Load Balancer WP-ALB, delete wp-target-group, and terminate WordPress-Web-App-1, WordPress-Web-App-2, and any Bastion Host instances from the EC2 console.
Step 2 — Delete Database & Shared File Systems: Delete the Amazon RDS MySQL instance wordpress-db (unchecking final snapshot creation and automated backup retention), remove mydbsubnetgroup, and delete the Amazon EFS file system along with its subnet mount targets.
**Step 3 — Release Networking Infrastructure: **Delete NATGateway1 (nat-0a8f37d9ad9a03146), wait for its state to reach Deleted, release the associated Elastic IP address back to AWS, detach and delete the Internet Gateway, and finally delete vpc-02b613dbb1276ffa4.
原文:https://www.a8q9.cn/en/article/traditional-3-tier-wordpress-website-deployment-on-aws-dd99a2.html



