Introduction
As part of the HNG DevOps Internship, I was tasked with setting up and configuring an NGINX web server on a fresh Ubuntu server. This blog documents my experience, challenges faced, and key takeaways.
Task Overview
The objective was to:
Install and configure NGINX.
Serve a custom HTML page at /var/www/html/index.html with the
message:
Welcome to DevOps Stage 0 - [Your Name]/[SlackName]
Deploy the server so it’s publicly accessible via an IP address.
Document the process in this blog.
Steps to Complete the Task
1️⃣ Updating the System
First, I updated the package list to ensure I had the latest dependencies:
sudo apt update
output:
vagrant@Hng-server:~$ sudo apt update
Hit:1 http://us.archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease [128 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease [128 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu focal-security InRelease [128 kB]
Get:5 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [3,770 kB]
Get:6 http://us.archive.ubuntu.com/ubuntu focal-updates/main Translation-en [575 kB]
Get:7 http://us.archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [3,545 kB]
Get:8 http://us.archive.ubuntu.com/ubuntu focal-updates/restricted Translation-en [496 kB]
Get:9 http://us.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [1,254 kB]
2️⃣ Installing NGINX
Next, I installed NGINX using the command:
sudo apt install nginx -y
I confirmed the installation with:
nginx -v
3️⃣ Starting and Enabling NGINX
I started the NGINX service and enabled it to launch on boot:
sudo systemctl start nginx
sudo systemctl enable nginx
To verify, I ran:
sudo systemctl status nginx
It showed Active (running), confirming a successful installation.
4️⃣ Configuring the Firewall
Since UFW (Uncomplicated Firewall) was inactive, I allowed HTTP traffic:
sudo ufw allow 'Nginx HTTP'
sudo ufw enable
5️⃣ Creating the Custom HTML Page
I modified the default index.html file to display the required message:
sudo nano /var/www/html/index.html
I replaced the content with:
Welcome to DevOps Stage 0 - [Your Name]/[SlackName]
Then saved and exited using CTRL + X, Y, and Enter.
6️⃣ Restarting NGINX
To apply the changes, I restarted the NGINX service:
sudo systemctl restart nginx
7️⃣ Testing the Web Server
To verify the setup, I ran:
curl http://localhost
This returned the expected message. Finally, I accessed the server from my browser using my public IP address:
http://<your-public-ip>/
Challenges Faced and Solutions
❌ Issue: Page Not Loading in Browser
✅ Solution: I checked my cloud provider’s Security Group Rules (for AWS EC2) and ensured port 80 was open.
❌ Issue: NGINX Not Running After Reboot
✅ Solution: I enabled NGINX to start on boot:
sudo systemctl enable nginx
Key Takeaways
Hands-on Experience: This task reinforced my understanding of
Linux web servers.Troubleshooting Skills: Debugging firewall and NGINX issues
improved my problem-solving abilities.Practical DevOps Knowledge: Deploying a functional web server
is a fundamental DevOps skill.
References
As part of the task, I referenced the following resources:
Conclusion
This was a great introduction to NGINX configuration and server deployment. I look forward to more challenging tasks in the internship!
Top comments (0)