- Newest
- Most votes
- Most comments
Hello,
Please try this solution it will be resolved your Question.
Step 1: Launch an EC2 Instance
Go to the EC2 Dashboard in the AWS Management Console.
Click "Launch Instance".
Choose an Amazon Machine Image (AMI), such as Amazon Linux 2 or Ubuntu.
Select an instance type (e.g., t2.micro).
Configure the security group to allow HTTP (port 80), a custom TCP rule for port 8080, and SSH (port 22) for your IP
Step 2: Configure Security Groups
Ensure your security group has the following rules:
Type Protocol Port Range Source HTTP TCP 80 0.0.0.0/0 Customs TCP TCP 8080 0.0.0.0/0 SSH TCP 22 Your IP
Step 3: Connect to the EC2 Instance
Connect to your EC2 instance using SSH
ssh -i /path/to/your-key.pem ec2-user@your-ec2-public-ip
Step 4: Install Dependencies
Update the package lists and install necessary software
sudo apt-get update
sudo apt-get install -y openjdk-11-jdk nodejs npm
Step 5: Set Up the Backend
Deploy your backend application:
Upload your backend application to the instance or clone your repository.
Ensure your backend listens on 0.0.0.0 (or the EC2 public IP) on port 8080.
Start your backend application (replace with your actual start command)
java -jar your-backend-application.jar
Step 6: Set Up the Frontend
Deploy your frontend application:
Upload your frontend application to the instance or clone your repository.
Configure the frontend to communicate with the backend by setting the backend API URL.
Start the frontend server to listen on 0.0.0.0 on port 80 (or port 4300 if preferred)
cd /path/to/your/frontend
npm install
ng build --prod
sudo npm install -g serve
sudo serve -s dist -l 80
Step 7: Ensure Communication Between Frontend and Backend
Set the backend API URL in the frontend configuration
// src/environments/environment.ts
export const environment = {
production: false,
apiUrl: 'http://your-ec2-public-ip:8080'
};
Relevant content
- asked a month ago
- asked 2 years ago
- asked 2 years ago
- AWS OFFICIALUpdated 5 months ago
- AWS OFFICIALUpdated 10 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 3 months ago