Introduction
As part of the HNG DevOps internship, I was tasked with configuring an NGINX web server on a fresh Ubuntu instance. This challenge aimed to assess my ability to work with basic web server configurations and deliver a functional static website. In this blog post, I will walk through my approach, highlight challenges I faced, and reflect on the learning experience.
Task Breakdown
The assignment required me to:
Install and configure the NGINX web server.
Serve a custom HTML page with the message:
"Welcome to DevOps Stage 0 - Daniel Jemiri/Survey"
Ensure the page is accessible via a public IP address.
Document the process and reflect on the experience.
Step 1: Setting Up the Ubuntu Server
I opted to use an Ubuntu 22.04 server on Google Cloud. The steps included:
Creating a Compute Engine instance and assigning a public IP.
Configuring firewall rules to allow traffic on port 80 (HTTP).
Connecting to the instance via SSH:
gcloud compute ssh --zone=<your-zone> <your-instance-name>
Step 2: Installing and Configuring NGINX
Installing NGINX
First, I updated the system and installed NGINX:
sudo apt update && sudo apt install -y nginx
To verify the installation:
nginx -v
I enable and check the status of the nginx
Enable NGINX to Start on Boot:
sudo systemctl enable nginx
Check NGINX Status:
sudo systemctl status nginx
You should see active (running) in the output.
Configuring the Web Server
To customize the default page, I modified the index.html file:
sudo nano /var/www/html/index.html
And added the required content:
<!DOCTYPE html>
<html>
<head>
<title>DevOps Stage 0</title>
</head>
<body>
<h1>Welcome to DevOps Stage 0 - Daniel Jemiri/Survey</h1>
</body>
</html>
Save and Exit:
:wq
After saving the file, I restarted NGINX to apply the changes:
sudo systemctl restart nginx
Step 3: Testing the Deployment
To confirm everything worked, I accessed my server’s public IP in a browser:
[YOUR_SERVER_IP](http://YOUR_SERVER_IP)
The page loaded successfully, displaying the custom message.
To ensure NGINX was running properly, I used:
sudo systemctl status nginx
Everything was set up correctly without errors.
Challenges and Solutions
Firewall Issues:
Initially, I couldn’t access the page from my browser.
Solution: I checked firewall rules and allowed HTTP traffic using:
gcloud compute firewall-rules create allow-http --allow tcp:80
File Permission Errors:
I encountered a permission error while editing index.html.
Solution: Used sudo to grant appropriate permissions:
sudo chmod 644 /var/www/html/index.html
Lessons Learned
This task provided hands-on experience with:
Installing and configuring NGINX.
Managing an Ubuntu server via SSH.
Debugging firewall and permission issues.
Deploying a static web page on a cloud server.
Understanding these core DevOps concepts is crucial as they align with roles like Site Reliability Engineers and Cloud Engineers.
Conclusion
Completing this task enhanced my ability to work with web servers and troubleshoot deployment issues. It reinforced my understanding of infrastructure setup, which is essential for any DevOps engineer. I look forward to tackling more complex challenges in the upcoming stages!
References and Further Reading
As I continue my journey, I’m inspired by the opportunities available at HNG Tech. Here are some roles that align with these aspirations and may inspire you too:
DevOps Engineers
Cloud Engineers
Site Reliability Engineers
Kubernetes Specialists
AWS Solutions Architects
Azure DevOps Engineers
Google Cloud Engineers
Top comments (0)