Deploy Angular Project on AWS EC2 Linux Instance

In this article, You will Learn How to deploy an Angular Application on AWS EC2 Instance in Detail.
You can also Learn Via My YouTube Video.
This article will consist of two parts.
- EC2 Instance Creation And Setup.
You can watch my Video to create EC2 instance.
- Deploying Application on EC2 Instance
Step 01: EC2 Instance Creation And Setup
Step 02: Deploying Application on EC2 Instance
1. Connect with your Instance with your terminal
$ chmod 400 YourInstanceKey.pem
$ ssh -i "YourInstanceKey.pem" ubuntu@ec2-InstancAPI.RegionOfInstance.compute.amazonaws.com
2. Prepare and Copy Project Build Using this command
You will need to use your local terminal, not the instance terminal.
Just run this command to create a build.
$ ng build
Then run the below command according to your paths. You can follow my youtube video as well.
$ scp -r -i desktop/desktop/testall/staging_.pem ./path/to/files/
<username>@<public-ip-address>:/pathwhere/you/need/to/copy3. Update The Instance and Install Nginx:
sudo yum update
sudo yum install nginx
sudo amazon-linux-extras install nginx1
sudo systemctl start nginx
sudo systemctl status nginx -lYou can confirm the Nginx setup by visiting your Public IP address in Browser.
Make sure HTTPS and HTTP Ports are allowed on EC2 Security Groups. As shown in my Youtube video. if you forget to allow it, Your IP address will not response.
4. Update Nginx. conf file:
Run this command to open Nginx.conf file
$sudo vim /etc/nginx/nginx.conf # run this commandAdd these lines in the Nginx configuration file.
location / {
autoindex on;
root /home/ec2-user/web;
try_files $uri /index.html;
}
root /usr/share/nginx/html;5. Give Some permissions
namei -om /usr/share/nginx/html namei -om /home/ec2-user/YourBuildName sudo chmod 755 /home/ec2-user namei -om /home/ec2-user/YourBuildName
5. Reload The
sudo systemctl reload nginx sudo systemctl restart nginx
6. Open The website Using your Instance IP Address in the Browser:
We are Done With the Angular project Deployment. Congrats.
If you Want to Learn Python, You can watch my ultimate Python Course on My Youtube Channel.
You can join there as well to share your Queries and suggestions. Facebook Facebook Group: https://web.facebook.com/groups/890525732087988/?mibextid=HsNCOg
You can Also Follow Me on My Social Media Platforms:
Thank You for reading!