Tools: How I Deployed a Production Server on AWS EC2 as a Fresher — Step by Step

Tools: How I Deployed a Production Server on AWS EC2 as a Fresher — Step by Step

A Little Background

Why AWS EC2?

What I Built

Step 1 — Launch Your EC2 Instance

Step 2 — Connect to Your Server

Step 3 — Install Nginx

Step 4 — Configure Nginx Server Blocks

Step 5 — Deploy Your Website Files

Step 6 — Set Up CI/CD with GitHub

Step 7 — Configure Security Groups Properly

Problems I Hit (And How I Solved Them)

Problem 1 — 403 Forbidden Error

Problem 2 — Port 80 Already in Use

Problem 3 — Can't Connect via SSH

Problem 4 — Changes Not Reflecting

What I Learned

What's Next

Final Thoughts A real story from someone who figured it out with no job, no mentor, and no money I'm Prashik. 25 years old. Computer Science graduate from Maharashtra.

No job yet. No salary. Just a laptop, an internet connection, and a burning desire to build something real. While most freshers were busy applying to jobs and waiting, I decided to do something different — I wanted to actually deploy something live on the internet. Not localhost. Not a tutorial project. A real, production-style server that anyone in the world could access. This is the story of how I did it — and everything I learned along the way. Honestly? Because every job description I read mentioned AWS. I kept seeing "AWS experience preferred" in job listings. I had done the AWS Cloud Practitioner course. I understood the concepts. But concepts and actually doing it are two completely different things. So I decided — let me just do it. Let me set up a real server, deploy a real website, and figure out the problems as they come. Spoiler: there were a LOT of problems. 😅 Here's what the final setup looked like: Sounds simple. Getting there was not. 😄 First things first — you need a server. Your server is now running somewhere in Amazon's data center. Pretty cool right? 🚀 On your local machine, open terminal and run: You're now INSIDE your cloud server. This felt like magic to me the first time. 😄 Nginx is the web server that will serve your website to the world. Now go to your EC2 public IP in a browser — you should see the Nginx welcome page. Your server is live on the internet. 🎉 Server blocks let you host multiple websites on one server (like virtual hosts in Apache). Add this configuration: Create your website directory and add your files: Now copy your website files here. Your site is live! This was my favourite part. Every time I push code to GitHub — it automatically deploys to the server. No manual copying files. Then create a simple deploy script: Now whenever you want to deploy — just SSH in and run ./deploy.sh. Or set up a GitHub Action to do it automatically! This is where I made mistakes and learned hard lessons. In AWS Console → EC2 → Security Groups, make sure you have: Important: Never leave port 22 open to 0.0.0.0/0 (everyone). Only allow your own IP for SSH. I learned this the hard way when I saw unknown login attempts in my logs. 😅 Cause: Wrong file permissions on /var/www/Fix: Cause: Apache was running alongside NginxFix: Cause: Security group didn't have port 22 openFix: Go to AWS Console → Security Groups → Edit Inbound Rules → Add SSH rule Cause: Nginx wasn't reloaded after config changesFix: After this I built a High Availability Architecture on AWS with: But that's a story for another article. 😄 If you're a fresher reading this feeling stuck — just start building. You don't need a job to gain experience. You don't need money to use AWS free tier. You don't need a mentor to figure things out. You just need to start, make mistakes, fix them, and keep going. That's exactly what I did. And I'm still going. 💪 If this helped you, follow me for more real stories about backend development, AWS, and the journey of building things from scratch. Connect with me on LinkedIn: linkedin.com/in/prashik-besekar

GitHub: github.com/prashikBesekar Templates let you quickly answer FAQs or store snippets for re-use. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse

Command

Copy

$ chmod 400 your-key-pair.pem ssh -i "your-key-pair.pem" ubuntu@your-ec2-public-ip chmod 400 your-key-pair.pem ssh -i "your-key-pair.pem" ubuntu@your-ec2-public-ip chmod 400 your-key-pair.pem ssh -i "your-key-pair.pem" ubuntu@your-ec2-public-ip -weight: 600;">sudo -weight: 500;">apt -weight: 500;">update -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install nginx -y -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start nginx -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable nginx -weight: 600;">sudo -weight: 500;">apt -weight: 500;">update -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install nginx -y -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start nginx -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable nginx -weight: 600;">sudo -weight: 500;">apt -weight: 500;">update -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install nginx -y -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start nginx -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable nginx -weight: 600;">sudo nano /etc/nginx/sites-available/mywebsite -weight: 600;">sudo nano /etc/nginx/sites-available/mywebsite -weight: 600;">sudo nano /etc/nginx/sites-available/mywebsite server { listen 80; server_name your-ec2-public-ip; root /var/www/mywebsite; index index.html; location / { try_files $uri $uri/ =404; } } server { listen 80; server_name your-ec2-public-ip; root /var/www/mywebsite; index index.html; location / { try_files $uri $uri/ =404; } } server { listen 80; server_name your-ec2-public-ip; root /var/www/mywebsite; index index.html; location / { try_files $uri $uri/ =404; } } -weight: 600;">sudo ln -s /etc/nginx/sites-available/mywebsite /etc/nginx/sites-enabled/ -weight: 600;">sudo nginx -t -weight: 600;">sudo -weight: 500;">systemctl reload nginx -weight: 600;">sudo ln -s /etc/nginx/sites-available/mywebsite /etc/nginx/sites-enabled/ -weight: 600;">sudo nginx -t -weight: 600;">sudo -weight: 500;">systemctl reload nginx -weight: 600;">sudo ln -s /etc/nginx/sites-available/mywebsite /etc/nginx/sites-enabled/ -weight: 600;">sudo nginx -t -weight: 600;">sudo -weight: 500;">systemctl reload nginx -weight: 600;">sudo mkdir -p /var/www/mywebsite -weight: 600;">sudo chown -R ubuntu:ubuntu /var/www/mywebsite -weight: 600;">sudo mkdir -p /var/www/mywebsite -weight: 600;">sudo chown -R ubuntu:ubuntu /var/www/mywebsite -weight: 600;">sudo mkdir -p /var/www/mywebsite -weight: 600;">sudo chown -R ubuntu:ubuntu /var/www/mywebsite cd /var/www/mywebsite -weight: 500;">git init -weight: 500;">git remote add origin https://github.com/yourusername/your-repo.-weight: 500;">git -weight: 500;">git pull origin main cd /var/www/mywebsite -weight: 500;">git init -weight: 500;">git remote add origin https://github.com/yourusername/your-repo.-weight: 500;">git -weight: 500;">git pull origin main cd /var/www/mywebsite -weight: 500;">git init -weight: 500;">git remote add origin https://github.com/yourusername/your-repo.-weight: 500;">git -weight: 500;">git pull origin main nano /home/ubuntu/deploy.sh nano /home/ubuntu/deploy.sh nano /home/ubuntu/deploy.sh #!/bin/bash cd /var/www/mywebsite -weight: 500;">git pull origin main -weight: 600;">sudo -weight: 500;">systemctl reload nginx echo "Deployed successfully!" #!/bin/bash cd /var/www/mywebsite -weight: 500;">git pull origin main -weight: 600;">sudo -weight: 500;">systemctl reload nginx echo "Deployed successfully!" #!/bin/bash cd /var/www/mywebsite -weight: 500;">git pull origin main -weight: 600;">sudo -weight: 500;">systemctl reload nginx echo "Deployed successfully!" chmod +x /home/ubuntu/deploy.sh chmod +x /home/ubuntu/deploy.sh chmod +x /home/ubuntu/deploy.sh -weight: 600;">sudo chown -R www-data:www-data /var/www/mywebsite -weight: 600;">sudo chmod -R 755 /var/www/mywebsite -weight: 600;">sudo chown -R www-data:www-data /var/www/mywebsite -weight: 600;">sudo chmod -R 755 /var/www/mywebsite -weight: 600;">sudo chown -R www-data:www-data /var/www/mywebsite -weight: 600;">sudo chmod -R 755 /var/www/mywebsite -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">stop apache2 -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">disable apache2 -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart nginx -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">stop apache2 -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">disable apache2 -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart nginx -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">stop apache2 -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">disable apache2 -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart nginx -weight: 600;">sudo nginx -t # Always test config first -weight: 600;">sudo -weight: 500;">systemctl reload nginx -weight: 600;">sudo nginx -t # Always test config first -weight: 600;">sudo -weight: 500;">systemctl reload nginx -weight: 600;">sudo nginx -t # Always test config first -weight: 600;">sudo -weight: 500;">systemctl reload nginx - AWS EC2 instance — a virtual server running Ubuntu in the cloud - Nginx — a web server configured with custom server blocks - GitHub CI/CD pipeline — automatic deployment every time I push code - AWS Security Groups — firewall rules to control traffic - A live, publicly accessible website — visible to anyone with the link - Go to AWS Console → EC2 → Launch Instance - Choose Ubuntu Server 22.04 LTS (free tier eligible) - Select t2.micro — this is free tier, costs you nothing - Create a new Key Pair — download the .pem file and keep it safe. If you lose this, you lose access to your server forever. - Configure Security Group — for now allow SSH (port 22) and HTTP (port 80) - Launch the instance - AWS Security Groups are your first line of defense — configure them carefully - Always run nginx -t before reloading — it saves you from breaking your server - File permissions matter more than you think in Linux - Git-based deployments are simple but powerful - You don't need a job to build production-level things - Every error message is just a puzzle waiting to be solved - The best way to learn cloud is to actually break things and fix them - Building something real gives you more confidence than any certification - Application Load Balancer - Auto Scaling Groups - Multiple Availability Zones - CloudWatch monitoring - 99.9% uptime design