Back to Blog
Dec 5, 20222 min read

Deploy Angular Project on AWS EC2 Linux Instance

AWSPythonLinuxNginx
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.

https://www.youtube.com/@CodeWithMuh

This article will consist of two parts.

  1. EC2 Instance Creation And Setup.

You can watch my Video to create EC2 instance.

  1. 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/copy

3. 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 -l

You 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 command

Add 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:

  1. Facebook
  2. Youtube
  3. Twitter & Instagram
  4. GitHub & Replit
  5. Upwork

Thank You for reading!

💬 Got questions? Ask me anything!