Skip to main content

Command Palette

Search for a command to run...

Deploying a Website on AWS EC2 instance using NGINX

Published
โ€ข2 min read
Deploying a Website on AWS EC2 instance using NGINX
U

๐Ÿš€ Hi everyone! I'm Utkarsh Gupta, IAM Consultant. I am very passionate for all things DevOps. Right now, I'm learning and working on some cool projects and I can't wait to share what I'm learning with you all!

๐Ÿ› ๏ธ Here's what's in my toolbox:

Linux Docker Kubernetes Jenkins AWS Python Prometheus Grafana Ansible Terraform

Join me as we explore AWS DevOps together. Let's learn and grow together in this ever-changing field!

๐Ÿค Feel free to connect with me for: Sharing experiences Friendly chats Learning together

Follow my journey on Hashnode and LinkedIn for daily updates. Let's dive into the world of DevOps together! ๐Ÿš€

#DevOps #AWS #DevOpsJourney #90DaysOfDevOps

Step 1: Launch an EC2 Instance :

Firstly Login to your AWS account and follow the steps :

  1. Go for Ec2 and click on launch instance.

  2. Give name for an instance and select Ubuntu as os.

  3. Select t2.micro instance type.

  4. Create a key pair.

  5. Create a Security Group and make sure these ports are allowed the traffic from anywhere:

    Port no. 80 for Http, Port no. 443 for Https and port 22 for SSH.

  6. Now Launch the instance with above configuration.

Note: We already covered how to launch EC2 instance in my Amazon Elastic Compute Cloud blog.

Step 2: Install Nginx on Ec2 instance

When instance is started running ,connect the ec2 instance through ssh using Windows PowerShell as shown in following images:

Now to install the nginx use following commands:

sudo apt update

sudo apt install nginx -y

check the status of nginx service by using systemctl status nginx command and you will get the output like this:

Also you can check by using Pubilc IP address of Ec2 instance with port number 80 on web browser and you will get the default page of nginx as shown below:

Note: If Nginx is not running with port 80, go to Edit inbound rules click "Add rule" add manually port 80.

Step 3: Deploy your website on nginx :

Nginx have its default index.html page in /var/www/html path , Replace your source code of your website by using command mv source path /* /var/www/html

Do all the process with following steps:

1.Create a directory for your source code of your project by using following command:

mkdir <Directory Name>

place your source code in this directory . Here my directory name is Project and You can check the default page of nginx by using cd /var/www/html command

Now Move your files into this path by using following command :

Step 4: Finally Launch The Website:

Now you can check by instance Public IP address:80 on web browser .Your website will be displayed:

Congratulations! ๐ŸŽ‰ You have successfully deploying a Website on AWS EC2 instance using NGINX.

Thankyou for the reading!๐Ÿ˜Š Keep Supporting ,learning and growing with each other .

More from this blog

Utkarsh Gupta's blog

27 posts