Introduction
I have always wanted to expand my skills from backend to cloud computing and DevOps. Knowing the nitty-gritty of how the infrastructure that facilitates software deployment has always fascinated me; hence, I joined the HNG internship.
As a finalist of HNG 10 when my focus was on becoming a finalist, this time I want to have fun and make a lot of techie friends while picking up DevOps skills and becoming a finalist.
The first task was setting up and configuring NGINX on a fresh Ubuntu server with the default HTML page overridden, so I decided to explore Google Cloud Platform (GCP) by creating a virtual machine (VM). Here's how I did it, the challenges I faced, and how this boosted my confidence in using GCP.
Task Overview
- Create a VM on GCP.
- SSH into the VM using gcloud.
- Install nginx on the VM
- Configure the firewall to accept HTTP and HTTPS.
- Change the default html page.
- Restart nginx.
1. Create a VM on GCP
I created a Google cloud account and logged into the Google cloud console Google cloud console.
On creating the account, press the Create a VM > Enable Compute Engine API > Create VM Instances. Configure the VM instance with the settings below:
Name: simple-nginx-configuration
Region/Zone: europe-west1-d
Machine Type: e2-micro (free tier)
Boot Disk: Ubuntu 20.04 LTS
Firewall: Enabled HTTP and HTTPS traffic
2. SSH into the VM
To SSH into the VM, download the gcloud tool using the official guide
Then I authenticated using
gcloud auth login
Then I configured the project ID
gcloud config set project [project_id]
NB: Replace the project_id with your project_id
Then I SSH into the VM using
gcloud compute ssh [INSTANCE_NAME] --zone [zone]
3. Install nginx on the VM
Update the package list
sudo apt update
Install nginx
sudo apt install nginx
Verify the installation
nginx -v
Start nginx
sudo systemctl start nginx
Enable nginx
sudo systemctl enable nginx
Check nginx status
sudo systemctl status nginx
NB: You will see running if the service is active/started
3. Configure the Firewall
Enable the firewall
sudo ufw enable
Allow HTTP
sudo ufw allow 'Nginx HTTP'
Allow HTTPS
sudo ufw allow 'Nginx HTTPS'
Allow SSH
sudo ufw allow 'OpenSSH'
Verify firewal rules
sudo ufw status
4. Change Default HTML Page
Open the html page using vi or nano (I used nano), edit and save it
sudo nano /var/www/html/index.html
<!DOCTYPE html>
<html>
<head>
<title>Welcome</title>
</head>
<body>
<h1>Welcome</h1>
<p>Welcome to DevOps Stage 0 - [Your Name]/[SlackName]</p>
</body>
</html>
I ensured the file has the correct permission
sudo chown -R www-data:www:data /var/www/html
sudo chmod -R 755 /var/www/html
5. Restart nginx
Restart nginx to reflect the changes
sudo systemctl restart nginx
Open the webpage in a browser using http://[your ip address]
. You should see content of the html page
How This Task Contributes to My Learning and Professional Goals
This task was a hands-on experience that deepened my understanding of creating and managing VM instances on GCP and configuring a web server(nginx).
References
Here are some roles that HNG can provide engineers for:
DevOps Engineers
Cloud Engineers
Site Reliability Engineers
Platform Engineers
Infrastructure Engineers
Kubernetes Specialists
CI/CD Pipeline Engineers
Monitoring/Observability Engineers
Docker Specialists
Top comments (0)