AWS EC2 (Elastic Compute Cloud) allows you to run virtual servers in the cloud. In this guide, we’ll deploy a live website on EC2 using secure, scalable and production-friendly steps.
1. Launch an EC2 Instance
Login to AWS Console → EC2 → Launch Instance. Choose Ubuntu or Amazon Linux as the operating system.
2. Configure Security Groups
- SSH – Port 22
- HTTP – Port 80
- HTTPS – Port 443
3. Connect to EC2 via SSH
ssh -i key.pem ubuntu@EC2_PUBLIC_IP
4. Install Web Server (Nginx)
sudo apt update
sudo apt install nginx -y
5. Deploy Website Files
Upload your project files to:
/var/www/html
6. Domain & SSL Setup
Point your domain to EC2 public IP and use Certbot to enable HTTPS.
Best Practices
- Use IAM roles instead of keys
- Enable firewall & monitoring
- Use CI/CD for deployments