Step-by-Step Guide to Deploying a Website on AWS

Step-by-Step Guide to Deploying a Website on AWS

Why AWS? A Quick Chat Before We Dive In

Alright, imagine you’ve just finished building your shiny new website. You’re fired up, ready to show it to the world. But where do you put it? If you’re like me — someone who’s wrestled with slow shared hosts and clunky control panels — AWS can feel like a breath of fresh air. But I get it, AWS also has that reputation. The vast, intimidating jungle of cloud services can make even the most seasoned folks hesitate.

But here’s the thing: deploying your site on AWS doesn’t have to be a brain-melter. In fact, once you get the hang of it, it’s like having your own high-powered hosting playground, with flexibility and speed that most smaller providers just can’t match.

So, grab your favorite coffee, and let’s walk through the deployment process step by step. No fluff. No jargon. Just the real talk you need.

Step 1: Start Small with an AWS Account

First things first — if you don’t have an AWS account yet, head over to aws.amazon.com and sign up. Fair warning: AWS loves to ask for your credit card upfront, but if you’re smart about it, you can stick to the free tier and avoid any surprise charges.

Pro tip: Set up billing alerts right away. Nothing like a little peace of mind when you’re experimenting.

Step 2: Choose Your Service – S3, EC2, or Elastic Beanstalk?

This is where many get stuck. AWS has a lot of services, and picking the right one feels like choosing a pizza topping at a place with 50 options. But here’s the simplest breakdown:

  • S3 (Simple Storage Service): Perfect for static sites — think HTML, CSS, JS only. Super cheap, super fast.
  • EC2 (Elastic Compute Cloud): Want full control? Need a backend? EC2 gives you a virtual server to do whatever you want.
  • Elastic Beanstalk: If you’re deploying an app and want AWS to handle the heavy lifting of scaling and managing servers, this is your pal.

For this guide, I’m focusing on deploying a basic but dynamic website using EC2, because learning the ropes here opens doors to a ton of custom setups.

Step 3: Launch Your EC2 Instance

Here’s where it starts to feel real. You’ll log into your AWS Management Console, navigate to EC2, and click “Launch Instance.”

Some quick pointers:

  • Pick your AMI: Amazon Linux 2 is a solid, stable choice.
  • Instance type: T2.micro is free-tier eligible and enough to get you started.
  • Configure security groups: This is your firewall. Open ports 22 (SSH), 80 (HTTP), and 443 (HTTPS) at minimum.
  • Key pairs: Create or use an existing key pair to securely connect via SSH. Don’t lose this — AWS won’t give it back!

Once launched, you’ll have a virtual server in the cloud. It’s like having your own little slice of internet real estate.

Step 4: Connect to Your Instance and Prepare Your Server

Time to get your hands dirty. Use a terminal (Mac/Linux) or PuTTY (Windows) to SSH into your new instance:

ssh -i <your-key-pair.pem> ec2-user@<your-ec2-public-ip>

Once connected, update your packages:

sudo yum update -y

Then, install a web server. Apache is a classic:

sudo yum install httpd -ysudo systemctl start httpdsudo systemctl enable httpd

Point your browser at your public IP — if everything’s golden, you’ll see the Apache test page. Victory!

Step 5: Upload Your Website Files

Now, to get your actual website live, you need to move your files to the server. There are a couple of ways:

  • SCP (Secure Copy): From your local machine, run:
scp -i <your-key-pair.pem> -r <your-website-folder>/* ec2-user@<your-ec2-public-ip>:/var/www/html/
  • FTP/SFTP clients: Tools like FileZilla can connect via SFTP using your key pair for a GUI drag-and-drop experience.

Remember, the default Apache root directory is /var/www/html. Replace the test page files there with your own.

Step 6: Tweak Permissions and Test

Permissions can be a sneaky culprit if your site won’t load or shows permission errors. On your server, run:

sudo chown -R ec2-user:ec2-user /var/www/htmlsudo chmod -R 755 /var/www/html

Then reload Apache:

sudo systemctl restart httpd

Refresh your browser — your site should be live and kicking.

Step 7: Secure Your Site with HTTPS

Running a website without HTTPS in 2024? That’s like sending postcards with your bank details on the front. Let’s secure your site with a free SSL certificate from Let’s Encrypt.

First, install Certbot:

sudo yum install epel-release -ysudo yum install certbot python2-certbot-apache -y

Then run:

sudo certbot --apache

Follow the prompts — it’s surprisingly straightforward. Certbot will grab the certificate and configure Apache to use it.

Pro tip: Set up automatic renewal so you don’t have to babysit your certs:

sudo crontab -e

Add this line:

0 0,12 * * * /usr/bin/certbot renew --quiet

Step 8: Keep Your Server Updated and Monitor

This one’s easy to overlook until it’s too late. Servers need love and care — updates, patches, backups. Set a reminder to SSH in weekly, run updates, and check logs.

Also, consider hooking up AWS CloudWatch for monitoring CPU, memory, and network traffic. It’s like having a health check for your server.

Wrapping Up: What’s Next?

Deploying your website on AWS EC2 isn’t rocket science, but it does require a bit of hustle. The first time you SSH in, upload files, and see your site live… that feeling sticks.

From here, you can explore load balancers, auto-scaling groups, or even containerize your app with ECS or EKS. AWS is a big ocean, but with each swim, you get stronger.

So, ready to get your site live on AWS? Give it a whirl, and if you hit a snag, remember: every hiccup is just a lesson in disguise.

Written by

Related Articles

Step-by-Step Guide to Deploying a Website on AWS