DEV Community

Cover image for How to install Nginx on an Amazon EC2 instance
Devops Den
Devops Den

Posted on • Edited on

How to install Nginx on an Amazon EC2 instance

Launch an EC2 Instance

  1. Go to the AWS Management Console.
  2. Launch a new EC2 instance.
  3. Choose the Amazon Machine Image (AMI) as Amazon Linux 2.
  4. Select the instance type (e.g., t2.micro for free tier).
  5. Configure the instance details, add storage, and configure the security group to allow HTTP (port 80) and SSH (port 22) access.
  6. Launch the instance and connect to it using SSH.

Connect to Your EC2 Instance

ssh -i "your-key-pair.pem" ec2-user@your-ec2-public-dns
Enter fullscreen mode Exit fullscreen mode

Update the Package Index

sudo yum update -y
Enter fullscreen mode Exit fullscreen mode

Install Nginx

sudo amazon-linux-extras install nginx1.12 -y

Start and Enable Nginx:

sudo systemctl start nginx
sudo systemctl enable nginx

Read More about Nginx

ThankYou

Top comments (0)