This document provides a step-by-step guide to setting up a Three-Tier Architecture using:
- Frontend: Angular application hosted on an Ubuntu server and deployed to Amazon S3 with CloudFront CDN.
- Backend: Spring Boot application running on an Ubuntu server, connecting to an Amazon RDS database.
- Database: Amazon RDS with MariaDB to store application data.
- 2 Ubuntu Linux Servers:
- Server 1: Frontend Application
- Server 2: Backend Application
- Amazon RDS Database (MariaDB)
- Amazon S3 Bucket (To host frontend files)
- CloudFront CDN (To cache frontend assets and improve performance)
- Log in to the AWS Console.
- Navigate to Amazon RDS > Create Database.
- Select MariaDB as the engine type.
- Choose the instance type and configure storage as per your requirement.
- Set Master Username and Password:
- Username:
admin - Password:
Admin123
- Username:
- Enable Public Accessibility and configure security groups.
- Click Create Database and wait for the instance to be available.
After creation, use the database endpoint to configure the backend.
mysql -h <rds_data_endpoint> -u admin -pAdmin123sudo apt update
sudo apt install mariadb-server
systemctl start mariadb
systemctl enable mariadbgit clone https://github.com/cloud-blitz/angular-java.gitCREATE DATABASE springbackend;
GRANT ALL PRIVILEGES ON springbackend.* TO 'username'@'localhost' IDENTIFIED BY 'your_password';
sudo mysql -u username -p springbackend < springbackend.sqlmysql -h <rds_data_endpoint> -u admin -pAdmin123
show databases;
show tables;
select * from tbl_workers;git clone https://github.com/cloud-blitz/angular-java.git
cd spring-backend
cd src/main/resources/
vim application.propertiesUpdate application.properties with:
spring.datasource.url=jdbc:mysql://database-1.c3ok6m0m4tt7.ap-northeast-1.rds.amazonaws.com:3306/springbackend?useSSL=false
spring.datasource.username=admin
spring.datasource.password=Admin1234
spring.jpa.generate-ddl=truesudo apt update
sudo apt install openjdk-8-jdk
sudo apt install mavenmvn clean package -Dmaven.test.skip=true
java -jar target/spring-backend-v1.jarNotes:
- Ensure necessary permissions for
sudocommands. - Use compatible Java and Maven versions.
- Adjust file paths according to your project structure.
git clone https://github.com/cloud-blitz/angular-java.git
cd angular-java
cd angular-frontendcd src/app/services/
vim worker.service.tsUpdate worker.service.ts (Line 12):
private getUrl: string = "http://57.180.55.30:8080/api/v1/workers"; // Replace with your backend IPsudo apt update
sudo apt install nodejs npm
node -v
npm -v
sudo npm install -g @angular/[email protected]
ng --versionnpm install
ng build cd dist/angular-frontend
ng serve --host 0.0.0.0 --port=80- Copy all files from
dist/angular-frontenddirectory. - Go to the Amazon S3 Console.
- Create a new bucket and enable Static Website Hosting.
- Upload all frontend files to the bucket.
- Configure bucket permissions to allow public access.
- Navigate to Amazon CloudFront.
- Create a new distribution.
- Select S3 Bucket as the origin.
- Configure caching and distribution settings.
- Deploy and note the CloudFront URL.
Your three-tier architecture is now successfully deployed with optimized performance and security!
This guide walks you through setting up a Three-Tier Architecture with an Angular frontend, a Spring Boot backend, and an Amazon RDS database. The frontend is hosted on S3 with CloudFront, while the backend runs on Ubuntu, connecting to RDS MariaDB. Following these steps ensures a scalable, secure, and high-performing deployment.
The error indicates that port 8080 is already being used by another process on your machine. To resolve this issue, you can either:
Stop the process using port 8080, or
Run your application on a different port.
Here’s how you can handle both scenarios:
->
ption 1: Stop the Process Using Port 8080 Step 1: Identify the Process Run the following command to find the process ID (PID) using port 8080:
On Linux/Mac:
sudo lsof -i :8080
Step 2: Stop the Process Once you have the PID, stop the process:
On Linux/Mac:
sudo kill -9 <PID>
