DEV Community

Cover image for Getting Started With DevOps as a Beginner
oluwatobiloba
oluwatobiloba

Posted on

Getting Started With DevOps as a Beginner

Introduction
As part of the DevOps Stage 0 challenge, I was tasked with installing and configuring an NGINX web server on an Ubuntu instance and serving a custom HTML page. This task aimed to test my ability to set up and configure a basic web server in a cloud environment. In this blog, I'll walk through my approach, the challenges I encountered, and the lessons I learned. Note that I am a beginner and you are welcome to try it out as a beginner as well. Before anything, ensure you have an account with a cloud service provider. I used AWS in my case.
Step-by-Step Approach
1. Setting Up the Server
I chose AWS EC2 as my cloud platform and launched a new Ubuntu 22.04 instance. Here's how I set up my server:

  • Logged into AWS Management Console and navigated to EC2.
  • Clicked Launch Instance and selected Ubuntu 22.04 LTS.
  • Configured instance type (t3.micro for free-tier eligibility) and created a new key pair.
  • Updated the security group to allow inbound traffic on ports 22 (SSH) and 80 (HTTP).
  • Launched the instance and noted the Public IPv4 address. 2. Connecting via SSH Once my instance was running, I connected to it using SSH: bash ssh -i my-key.pem ubuntu@your-public-ip

To prevent permission issues, I set the correct permissions for the key file:
bash
chmod 400 my-key.pem

3. Installing and Configuring NGINX
After successfully accessing the server, I proceeded with installing and configuring NGINX:
bash
sudo apt update && sudo apt upgrade -y
sudo apt install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx

I then verified that NGINX was running using:
bash
systemctl status nginx

4. Creating the Custom HTML Page
To display the required message, I edited the default index.html file:

bash
cd /var/www/html
sudo nano index.html

I added the following content:
html
<!DOCTYPE html>


 
 
 DevOps Stage 0


 

Welcome to DevOps Stage 0 - [Your Name]/[SlackName]



I then saved the file and restarted NGINX to apply the changes:

bash
sudo systemctl restart nginx

5. Making the Page Publicly Accessible
To allow web traffic, I updated the firewall settings:

bash
sudo ufw allow 'Nginx Full'
sudo ufw enable

I also ensured that my AWS Security Group allowed port 80 (HTTP) traffic.
Finally, I accessed my custom web page at: http://my-public-ip/
See the screenshot below.

Image description

Challenges and How I Overcame Them

1. SSH Connection Timeout
Issue: Initially, I faced an issue where SSH could not connect to my EC2 instance (Connection timed out).

Solution:

  • Verified that the instance was running.
  • Checked the security group settings and found that SSH (port 22) was not allowed. I updated it to allow SSH traffic from my IP.
  • Ensured my key pair file had the correct permissions (chmod 400 my-key.pem).

2. NGINX Not Accessible on Browser
Issue: Even after starting NGINX, I couldn't access my web page.
Solution:

  • Allowed HTTP traffic in UFW (Uncomplicated Firewall) on Ubuntu.
  • Updated my AWS Security Group to allow port 80 traffic.
  • Restarted NGINX to ensure the configuration was applied.

3. File Editing Challenges
Issue: I initially struggled with using nano for editing the HTML file.
Solution: I familiarized myself with basic nano commands:

  • CTRL + X to exit.
  • Y to save changes.
  • Enter to confirm.

Lessons Learned

  • Cloud Setup Basics: Learned how to set up and configure an EC2 instance on AWS.
  • Web Server Configuration: Understood the fundamentals of installing and running NGINX.
  • Networking & Security: Gained insights into managing firewall rules and AWS security groups.
  • Debugging & Troubleshooting: Faced real-world challenges and learned to resolve them effectively.

How This Task Contributes to My Professional Growth
This task has helped me understand essential DevOps concepts, such as:

  • Infrastructure as Code (IaC): Automating server setups.
  • Web Server Management: Handling NGINX configuration.
  • Security Best Practices: Ensuring proper firewall and access control settings. These are crucial skills for roles like DevOps Engineers and Cloud Engineers.

Conclusion
This task was a great introduction to configuring web servers and troubleshooting real-world issues. By setting up an Ubuntu instance on AWS, installing NGINX, and resolving common challenges, I gained hands-on experience in cloud infrastructure management. I'm excited to apply these skills to more complex DevOps tasks in the future!

References:
- DevOps Engineers

Top comments (0)