✅ Day 16 of My Cloud Journey ☁️ — Deploying a Static Website Using NGINX on EC2

Today I explored how to host a static website using NGINX on an EC2 instance. This is a fundamental real-world scenario that helps understand web server configuration, static content delivery, and securing access via security groups.
🧱 Why NGINX?
NGINX is a high-performance web server that’s great for serving static content like HTML, CSS, JavaScript, images, etc. It’s also widely used as a reverse proxy, load balancer, and caching server — so learning it now pays off later.
🔧 Step-by-Step Setup
Launch an EC2 Instance
Choose Amazon Linux 2 or Ubuntu
Place it in a public subnet
Attach a Security Group allowing:
TCP Port 22 (SSH) from your IP
TCP Port 80 (HTTP) from
0.0.0.0/0
Connect to EC2 via SSH
Install NGINX
For Amazon Linux:
sudo yum install nginx -y sudo systemctl start nginx sudo systemctl enable nginx
For Ubuntu:
sudo apt update sudo apt install nginx -y sudo systemctl start nginx sudo systemctl enable nginx
Upload Your Static Website
Replace default content:
sudo rm -rf /usr/share/nginx/html/*
Upload your
index.html
,styles.css
, etc. viascp
or manually using an SFTP client.Place files in:
/usr/share/nginx/html/
Verify
Visit your EC2's public IP in the browser:
http://<public-ip>
Your static site should load ✅
🧰 Optional Enhancements
Add a custom domain via Route 53
Use CloudFront for caching and faster delivery
Add SSL (using Let’s Encrypt or ACM for HTTPS)
Store static content in S3 and proxy through NGINX
🤝 Key Learnings
Hosting static files with NGINX is straightforward
Importance of correct file permissions and paths
Keeping web servers stateless = better scaling
Security Group config directly impacts site accessibility
📸 Output
📅 What’s Next?
Day 17: Deep Dive into Hosting WordPress on AWS EC2 using LAMP Stack (Apache)
Tomorrow, I’ll walk through launching a WordPress blog by manually setting up the LAMP stack — Linux, Apache, MySQL, and PHP — on an EC2 instance.
I’ll also cover the key differences between LAMP and LEMP (where NGINX replaces Apache) and when to use which. This will give me the flexibility to host dynamic web apps using either stack in real-world projects.
Subscribe to my newsletter
Read articles from Pratik Das directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
