DEV Community

Victor Eze
Victor Eze

Posted on

Configuring NGINX Web Server on Amazon EC2 Instance using Ubuntu server. My Stage 0 DevOps Task

INTRODUCTION

Handling millions of request by a website without crash can be attributed to the power of a well-configured web server and NGINX is a popular choice for its speed and efficiency. This post provides a step-by-step guide to configuring the NGINX web server on an Amazon EC2 instance using Ubuntu Server. I'll show you how to install and configure NGINX on an Amazon EC2 instance running Ubuntu Server. This is my first project at HNG DevOps internship training.

Project Setup

*Launch an Amazon EC2 Instance.
*

  • Instance name:  Nginx instance
  • AMI: Ubuntu server 24.04
  • Instance type: t2 micro
  • Key pair: nginx-key
  • Security group: Allow SHH traffic form anywhere
  • port: Port 80 (HTTP): This allows access to your web server over HTTP.

Image description

Connect to the EC2 instance:

Connect this by selecting on your instance, click connect and use Ec2 direct connect.

Update the package list:

sudo apt update
Enter fullscreen mode Exit fullscreen mode

Image description

Installation of Nginx:

sudo apt install nginx -y

Enter fullscreen mode Exit fullscreen mode

Image description

Start and enable nginx to run on boot:

sudo systemctl start nginx 
sudo systemctl enable nginx
Enter fullscreen mode Exit fullscreen mode

Image description

*Configure the html page:
*

First open the index.html file:

sudo nano /var/www/html/index.html
Enter fullscreen mode Exit fullscreen mode

Then,
Add the html content
Save and exist

Image description

Restart the nginx server to effect the change:

sudo systemctl restart nginx
Enter fullscreen mode Exit fullscreen mode

Verify if the nginx web server is running:

sudo systemctl status nginx
Enter fullscreen mode Exit fullscreen mode

Image description

Open a web browser and verify:

http://your-server-ip
Enter fullscreen mode Exit fullscreen mode

Image description

Image description

_CHALLENGES FACED WORKING ON THIS PROJECT.
_

While creating my instance I encountered issues choosing my CIDR block as it keeps giving error message that its overlapping so I had to choose a different CIDR block different from what I had before.

CONCLUSION:
By following these steps, you now have a fully functional NGINX web server running on your EC2 instance. This is a fundamental skill for any developer or DevOps engineer, enabling you to host websites, APIs, and other web applications. NGINX's performance and reliability will provide a solid foundation for your projects.

REFERENCES:
DevOps Engineer
Cloud Engineers.
Infrastructure Engineers.
AWS Solutions Architects.
Azure DevOps Engineer.
Google Cloud Engineer.
CI/CD Pipeline Engineers..

Top comments (2)

Collapse
 
ajisegiri_ademola_681df5c profile image
Olajide Ajisegiri

nice work !

Collapse
 
victor_eze_8173729864a01b profile image
Victor Eze

Thank you so much, comrade!!!