DEV Community

Adeitan Abimbola Moses
Adeitan Abimbola Moses

Posted on

Beginner's Guide: How i installed Nginx on AWS EC2 Instance

Deploying a web server on the cloud is easier than ever, especially with AWS. In this article, I’ll walk you through the steps I took to install NGINX on an Ubuntu-based EC2 instance using AWS.

Before starting, ensure you have:

  1. An AWS account: If you dont have an AWS account, you can simply register at https://amazon.aws.com

Registration page

and if you have an account, login using your root email.

Image description

once you are logged in,

  1. Create an EC2 Instance: Search for Instance on the search bar and click on launch instance

Image description

To create your instance, do the following
a. Type your instance name e.g my_nginx_instance note: do not put in spaces in between your instance name.

Image description

b. Select Ubuntu as your OS (Operating System)

Image description

c. Select your instance type and choose t3.micro for the purpose of our testing and this article.
d. Create your keypair: Keypairs are very important and must be kept and saved. You can either use an existing keypair if you have or create a new keypair
e.Next is to create your security group. For the purpose of this article..kindly select allow SSH from anywhere and Allow SSH from internet.

Image description

f. Then click on Launch Instance.

Image description

  1. Open your Gitbash and we can run some commands from the terminal.
  2. Make sure to change directory to where your keypair was downloaded. As for me, my keypair is currently downloaded in my downloads folder. so i am going to cd into downloads.

Image description

  1. SSh into your Ec2 Instance

Image description

  1. Update your ubuntu OS: sudo apt update -y

Image description

  1. Next is to install Nginx: sudo apt install nginx -y

Image description

  1. Next is to start your Nginx: sudo systemctl start nginx
  2. You can check status of your Nginx: sudo systemctl status nginx

Image description

Image description

  1. Next is to enable Nginx: sudo systemctl enable nginx

Image description

  1. Access your Ip address and you will get to see Nginx Landing page

Image description

  1. You can go ahead to modify the landing page to your own words or text. using sudo nano /var/www/html/index.nginx-debian.html

I hope i was able to take you through my basic step in setting up an nginx server on an AWS instance.

Thank you.

Top comments (0)