HNG DevOps Internship Task 1: Setting Up and Configuring NGINX on Ubuntu Server
Configuring an EC2 Instance
For this task, we were required to use any cloud service provider to set up and configure NGINX on a fresh Ubuntu server. I opted for AWS due to my familiarity with its environment and the availability of its free basic tier.
Steps to Launch an EC2 Instance
- Instance Name: HNG
- AMI (Amazon Machine Image): Ubuntu 22.04 LTS
- Instance Type: t3.micro (Free Tier eligible)
-
Security Group Configuration:
- Allowed SSH access (Port 22) from anywhere (0.0.0.0/0)
- Allowed HTTP access (Port 80) from anywhere (0.0.0.0/0)
-
Key Pair: Generated a
.pem
key for SSH access to the server.
Connecting to the Server via SSH
Once the instance was running, I connected to it using SSH with the following command:
ssh -i your-key.pem ubuntu@your-public-ip
Installing and Configuring NGINX
I installed NGINX using the following commands:
sudo apt update && sudo apt install nginx -y
To ensure NGINX starts on boot and runs immediately, I executed:
sudo systemctl start nginx
sudo systemctl enable nginx
Creating an HTML File
I created an HTML file to display a simple message on the web server.
Command to open the file using the Nano text editor:
sudo nano /var/www/html/index.html
HTML Code:
<!DOCTYPE html>
<html>
<head>
<title>My First Web Page</title>
</head>
<body>
<p>Welcome to DevOps Stage 0 - my name / slack name</p>
</body>
</html>
Restarting NGINX and Verifying the Setup
To apply the changes, I restarted the NGINX server:
sudo service nginx restart
Testing in a Web Browser
Finally, I opened a web browser and entered my public IP address. If everything was set up correctly, the browser should display:
Welcome to DevOps Stage 0 - your name / slack ID
Conclusion
This task demonstrated the ability to:
- Launch and configure an EC2 instance on AWS
- Install and set up NGINX
- Create and serve a basic HTML page
The server is now running successfully with NGINX serving a custom webpage.
Top comments (0)