Setting Up Nginx on Ubuntu AWS EC2: A Step-by-Step Guide
HNG Internship Stage 0

Hey Viewer, I'm Kyle Robins, Devops / Full-stack Engineer based in Nairobi Kenya. Am passionate about Web development & Content Creation.
Search for a command to run...
HNG Internship Stage 0

Hey Viewer, I'm Kyle Robins, Devops / Full-stack Engineer based in Nairobi Kenya. Am passionate about Web development & Content Creation.
No comments yet. Be the first to comment.
Kubernetes has become the go-to solution for container orchestration, offering robust capabilities to automate the deployment, scaling, and management of containerized applications. In this blog post, we will walk through the process of deploying a s...

Definition - Kubernetes is an opensource orchestration engine for automating deployments,scaling, and managing containerized applications it was created by Google but its now actively maintained by Cloud Native Computing Foundation. Kubernetes facili...

Understanding Basics and Must-Know Methods

A Beginner's Guide to for, while, and do-while in JavaScript

As a DevOps engineer, setting up web servers is a common task. In this guide, I'll walk you through the process of installing and configuring Nginx on an Ubuntu EC2 instance. I'll be using Termius as my terminal client for SSH connections, which provides a clean and user-friendly interface for managing server connections.
An AWS account with an EC2 instance running Ubuntu 22.04 LTS
SSH access to your instance
Basic knowledge of Linux commands
Termius installed on your machine (iTerm2 (Mac Os), Putty (Win Os) )
I'm using Termius to manage my SSH connections. After launching my EC2 instance (t2.nano in this case),

I added it to Termius using the public IP address (54.239.173.240 in my case) and my SSH credentials. Termius makes it easy to organize and manage multiple server connections with its intuitive interface.

First, let's check our Ubuntu version to ensure we're working with the correct system:
cat /etc/os-release
As shown in the output, we're running Ubuntu 22.04.5 LTS (Jammy Jellyfish), which is perfect for our setup.

Now, let's update our package lists and install Nginx:
sudo apt update && sudo apt install nginx -y
This command updates the package repository and installs Nginx in one go. The -y flag automatically answers "yes" to the installation prompt.

After installation, we can verify Nginx's version and status:
nginx -v
This shows we've installed Nginx version 1.18.0.

To check if Nginx is running properly:
sudo systemctl status nginx
The output shows that Nginx is active and running, with the following details:
Service is loaded and enabled
Active status: running
Process ID and worker processes are properly initialized
Memory usage and CPU time are being tracked

And there you have it! We've successfully installed Nginx on our Ubuntu EC2 instance. The server is now ready to serve web content. In future posts, we'll explore how to configure Nginx for hosting websites and setting up reverse proxies.
This is just my cue for an exiting 8 week Devops Internship at HNG
After confirming Nginx was running properly, customize the default welcome page. To do this, modify the default HTML file:
sudo nano /var/www/html/index.html
I replaced the contents with a custom welcome message:
<h1>Welcome to DevOps Stage 0 – JaneDoe/@janedevops</h1>
To ensure our web server is accessible, we need to configure the firewall to allow HTTP traffic:
sudo ufw allow 80
After this, you can access your web server by entering your EC2 instance's public IP address in a web browser. Make sure your EC2 security group also allows inbound traffic on port 80 (HTTP).
Remember to always follow AWS security best practices and keep your system updated for optimal performance and security.