Business Case Scenario:**Company Background: **Joysontech is a travel agency specializing in global adventure tours, such as trekking and luxury cruises. They plan to enhance operations and customer engagement with a new Joomla-based website.
**Project Goal: **Launch a scalable, secure website as a central hub for travel services to support company growth.
Architecture Overview:Two-Tier Architecture:
Web Tier: Uses Apache on an EC2 instance to host Joomla and manage HTTP requests.
Database Tier: Utilizes Amazon RDS for MySQL data management.
Benefits:
- **Scalability: **Independent scaling for web and database tiers.
Security: Isolated database enhances security.
Manageability: Easier maintenance and upgrades.
Reliability: RDS ensures data protection and availability.
Use Case:
Joomla offers robust, flexible CMS features, supporting extensions for dynamic content, booking, and e-commerce, enhancing user engagement.
Overview
In this topic will cover how to setup Web Tier with EC2 instances with Joomla installed, Database Tier with AWS RDS with MySQL database, how to create AMI, Custom VPC, internet gateway, Subnets, auto scaling groups, dynamic scaling policies, Lunch Template, application load balancer and target group on AWS and will start from foundational, advanced, and complex tasks as outlined below.
_Get ready for some fun :)_Foundational:
- Set Up Networking, Web Tier, Database Tier
- Install and Configure Joomla and Security groups
- Test the website and post a sample blog to verify.
Advanced:
- Deploy an Additional EC2 Instance and automate Joomla Installation using user data.
- Set Up an Application Load Balancer (ALB)
- Modify Security Groups to allow traffic from ALB to EC2 and test the Load Balancer
- Test failover and load distribution to ensure high availability.
Complex:
- Create an AMI
- Deploy to an Auto Scaling Group and Configure Auto Scaling Policies
- Test Auto Scaling
- Simulate traffic to test the auto-scaling capabilities.
- Ensure that the Auto Scaling Group maintains at least 2 instances and can scale up to 3 instances as needed.
Check out the step-by-step details on project tiers here
Foundational:
Step 1: Set Up Networking
Create a Custom VPC:
Open the VPC Dashboard and Click on “Create VPC” and choose VPC and more option
For IPv4 configure your CIDR block (e.g., 10.0.0.0/16).
Create two public subnets (e.g., 10.0.1.0/24 and 10.0.2.0/24).
Create two private subnets (e.g., 10.0.3.0/24 and 10.0.4.0/24).
And then click on “Create VPC”.
Please note: the VPC and more option will also create internet gateway, attach internet gateway to the VPC, create the route tables and associate them with public and private subnet and will also add route to internet gateway for public subnets.Step 2: Set Up Web Tier
Launch Ubuntu EC2 Instance:
Choose an Amazon Machine Image (AMI) for Ubuntu.
Set instance type, configure security groups (allow HTTP and SSH).
Choose the VPC you created previously and place this EC2 instance in public-subnet1
Enable auto-assign public IP and click on “Launch instance”
Step 3: Set Up Database Tier
Launch MySQL RDS Instance:
Choose MySQL as the database engine and configure the instance in one of the private subnets.
Set security group to allow connections from the EC2 instance (allow port 3306 for inbound rules).
Create Admin user and password to access and setup database connection to Joomla.
Step 4: Install and Configure Joomla
- Access into EC2 instance via SSH and Download Joomla and install Joomla. Full guide and commands here.
- Once you have install Joomla Configure the database settings, and complete the installation.
Full guide and commands here.Step 5: Testing
- Test access to the website and functionality by posting a sample blog.
Advanced:
- Deploy an Additional EC2 Instance:
Launch another EC2 instance in subnet-public2 through the AWS Console.
Automate Joomla Installation:
Once the EC2 instance is launched SSH into it and create a script called install_joomla.sh with the below code.
!/bin/bash
Update Package List:
sudo apt update
Install Apache, PHP, and Required Modules:
sudo apt install -y apache2 php libapache2-mod-php php-mysql php-xml php-gd unzip
Start and Enable Apache:
sudo systemctl start apache2
sudo systemctl enable apache2
Download Joomla:
cd /var/www/html
sudo curl -L -o joomla.zip https://github.com/joomla/joomla-cms/releases/download/3.9.28/Joomla_3.9.28-Stable-Full_Package.zip
Extract Joomla
sudo unzip joomla.zip
Set the correct permissions:
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 755 /var/www/html
Remove the default Apache index.html file:
sudo rm /var/www/html/index.html
Change ownership of /etc/apache2/mods-enabled so we can modify Apache Configuration File:
cd /etc/apache2/mods-enabled
sudo chown -R ubuntu:ubuntu /etc/apache2/mods-enabled
Adjust the Directory Index Setting:
Make sure the index.php comes before index.html. The line should look like this:
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
echo "DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm" | sudo tee dir.conf
Restart Apache:
sudo systemctl restart apache2
- Change the ownership of the install_joomla.sh and make it executable Run the script on the EC2 instance to download and install Joomla.
- Once the Joomla installation is done follow the GIF in step 4 in foundations task to configure Joomla through web browser.
- Set Up an Application Load Balancer (ALB):
- Create an ALB and set it to distribute incoming traffic to both EC2 instances.
- Ensure the ALB is associated properly with subnets and security groups.
Please note: Create a security and Target group before creating ALB as its easier that way. I have already created them before setting up the ALB.4. Modify Security Groups:
- Update EC2 instances’ security groups to accept traffic only from the ALB security group.
- Test the Load Balancer:
- Validate the ALB’s effectiveness in balancing load and handling failovers.
I will stop one of the instance and once the website fails for 2 or 3 consecutive times the ALB will direct all traffic to other health EC2 instance.
Complex:
- Create an AMI:
Create an AMI from one of the configured EC2 instances to include Joomla installation and configurations.
Deploy to an Auto Scaling Group:
Create a Launch Template and an ASG utilizing the created AMI.
Set parameters for the ASG to maintain between 2 to 3 instances
Configure the ASG to use the previously created Application Load Balancer
Configure Auto Scaling Policies:
Define policies for scaling based on CPU metrics or desired conditions.
Test Auto Scaling:
Simulate traffic to test the auto-scaling capabilities.
- To test, you can use a stress test tool like stress:
- I have SSH into both of my instances and install the stress tool.
- Run a command like stress --cpu 8 --timeout 60to simulate high CPU usage.
- I am using htop to track the CPU usage.
After 6–8 min in Auto scaling group under activity tab you can see the its launching 2 new EC2 instances and also check this on EC2 instance Dashboard.
It will automatically scale in when the CPU usage is below 50 percent. So it will Dain the connection and terminate the EC2 instance and maintain the desire/minimum instances stated in ASG.
If this post was helpful, please click the clap 👏 button below a few times to show your support! ⬇
SOCIAL SHARE CARD GENERATOR