DEV Community

akpomuetata fejiro
akpomuetata fejiro

Posted on

HNG DEVOPS STAGE 0: Configuring Nginx on an ubuntu server

INTRODUCTION
Our first task as being part of the HNG DevOps internship program was configuring Nginx on an ubuntu server and also customizing the HTML page.

Requirements

  • Amazon linux 2, t2.micro instance
  • port 22 (to enable ssh)
  • port 80 (to enable access from anywhere)

steps
connecting to the instance
After setting up my instance with the appropriate keypair and security group, i launched the instanced and waited for it to run. thereafter i connected to the instance via the Ec2 instance connect.

Image description

Installing Nginx and starting it
the following commands are used in installing nginx on amazon linux 2
sudo yum update - to update any needed packages
sudo amazon-linux-extras install nginx1 - to install nginx
sudo systemctl start nginx - to start nginx
sudo systemctl enable nginx - to enable nginx
sudo systemctl status nginx - to verify that nginx is runing

Image description

To edit the index.html file
To add content to the index.html file
firstly you move to the location of the index.html file

Image description

Next i checked if i had the write permission to the index.html file

Image description

i didn't have write permission to the index.html file so i had to grant myself that permission before i was able to edit the file

Image description

after granting myself permission to the index.html file, i used nano to edit the file

Image description
after editing the file, i used ctrl + s to save the file and ctrl + x to exit the file.

next i restarted the nginx server

Image description

At this point i copied the public ip of my ec2 instance and pasted it on my browser and it displayed the nginx page with the edits i made in it

Image description

Challenges and solutions proffered

  • The major challenge i encountered was moving into the location of the index.html file. since i was using the amazon linux 2, the location of the index.html file wasn't /var/www/html. so i had to look for where the file was and i found it located at /usr/share/nginx/html

Learning Outcome
This task has enabled me to learn the requirements for launching instances and hosting simple servers. It has also broaden my knowledge in the DevOps world.

References
https://hng.tech/hire/devops-engineers
https://hng.tech/hire/linux-developers

Top comments (0)