DEV Community

TAMUNO-OPU KIO-HARRY
TAMUNO-OPU KIO-HARRY

Posted on

Configuring NGINX Web server On AWS EC2

HNG DevOps Internship Task 1: Setting Up and Configuring NGINX on Ubuntu Server

Configuring an EC2 Instance

For this task, we were required to use any cloud service provider to set up and configure NGINX on a fresh Ubuntu server. I opted for AWS due to my familiarity with its environment and the availability of its free basic tier.

Steps to Launch an EC2 Instance

  1. Instance Name: HNG
  2. AMI (Amazon Machine Image): Ubuntu 22.04 LTS
  3. Instance Type: t3.micro (Free Tier eligible)
  4. Security Group Configuration:
    • Allowed SSH access (Port 22) from anywhere (0.0.0.0/0)
    • Allowed HTTP access (Port 80) from anywhere (0.0.0.0/0)
  5. Key Pair: Generated a .pem key for SSH access to the server.

Connecting to the Server via SSH

Once the instance was running, I connected to it using SSH with the following command:

ssh -i your-key.pem ubuntu@your-public-ip
Enter fullscreen mode Exit fullscreen mode

Installing and Configuring NGINX

I installed NGINX using the following commands:

sudo apt update && sudo apt install nginx -y
Enter fullscreen mode Exit fullscreen mode

To ensure NGINX starts on boot and runs immediately, I executed:

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

Creating an HTML File

I created an HTML file to display a simple message on the web server.

Command to open the file using the Nano text editor:

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

HTML Code:

<!DOCTYPE html>
<html>
<head>
    <title>My First Web Page</title>
</head>
<body>
    <p>Welcome to DevOps Stage 0 - my name / slack name</p>
</body>
</html>
Enter fullscreen mode Exit fullscreen mode

Restarting NGINX and Verifying the Setup

To apply the changes, I restarted the NGINX server:

sudo service nginx restart
Enter fullscreen mode Exit fullscreen mode

Testing in a Web Browser

Finally, I opened a web browser and entered my public IP address. If everything was set up correctly, the browser should display:

Welcome to DevOps Stage 0 - your name / slack ID
Enter fullscreen mode Exit fullscreen mode

Conclusion

This task demonstrated the ability to:

  • Launch and configure an EC2 instance on AWS
  • Install and set up NGINX
  • Create and serve a basic HTML page

The server is now running successfully with NGINX serving a custom webpage.

DevOps Engineers
Cloud Engineers

Retry later

Top comments (0)

Retry later
Retry later