HNG DevOps - Stage 0

HNG DevOps - Stage 0

Task - NGINX configuration

Introduction

Starting my HNG Internship, one of the first tasks assigned to DevOps interns was to set up NGINX on Ubuntu and configure it to serve a custom web page. This task aimed to evaluate our ability to install, configure, and troubleshoot a web server from scratch. In this blog post, I’ll walk you through how I approached and completed this task, including any challenges I faced and the key lessons I learned.


Task Overview

The task required me to:

  1. Install the NGINX web server and ensure it is running.

  2. Configure NGINX to serve a custom HTML page as the default page with the message:

Welcome to DevOps Stage 0 - Victor Iliya/Non-Existent
  1. Write a blog post that documents your experience with this task.

Step-by-Step Guide

Install NGINX

  1. Created the Web Server:

    The first thing I did was to create an EC2 instance on AWS to be my web server. I used an ubuntu AMI.

  1. Connect to the instance

    There are many ways to connect to an EC2 instance, I used the EC2 instance connect.

  1. Update Ubuntu

    Once connected to the EC2 instance, the first thing t do it to update the Linux server by running the code below.

sudo apt update
  1. Install NGINX

    The next step is to install the NGINX service

sudo apt install nginx -y
  1. Enable and start NGINX

    After installation, I enabled and started the NGINX service:

sudo systemctl enable nginx
sudo systemctl start nginx
  1. Confirm if NGINX is running
systemctl status nginx

If everything worked correctly, you should have the following:

Configure the Default Web Page

  1. Modify the default index.html page:

    For the server to display the page, you need to modify the default index.html page located at /vat/www/html/index.html.

    Use the vim command for this as such:

vim /var/www/html/index.html

Now, to modify text files with vim, press the “ i “ key on the keyboard which is for insert, and now you’d be able to enter the text you want, in my case it would be “Welcome to DevOps Stage 0 - Victor Iliya/ Non-Existent“

Now to save the file, perform the following:

  • press the “ esc “ key to exit the insert mode.

  • type :wq! and press the enter key to save the file and close the vim editor.

Note: If the permission is denied, use sudo as such:

sudo vim /var/www/html/index.html
  1. Restart the NGINX server

    Restart the NGINX server to apply the changes

     sudo systemctl restart nginx
    

Open your web page

Go back to your instance and find your public ip address, use this to access the site you’ve just made.

Note: Ensure the security groups for your instance allows HTTP traffic on port 80

  1. Hands-on experience installing and configuring NGINX

  2. Debugging and troubleshooting web server issues

  3. Improved Linux server management skills

References

I explored different engineering roles at HNG for future career growth:

This was a great learning experience, and I’m excited for what’s next!