DEV Community

Cover image for 🚀 Steps to Create a Server in Amazon EC2
Pavithran G
Pavithran G

Posted on

🚀 Steps to Create a Server in Amazon EC2

1. Log in to AWS Management Console


2. Launch an EC2 Instance

  1. From the Services menu → Select EC2.
  2. Click Launch Instance.
  3. Give your instance a name (e.g., MyServer).

3. Choose an Amazon Machine Image (AMI)

Select an OS (commonly used options):

  • Amazon Linux 2 (Free tier eligible)
  • Ubuntu Server (20.04/22.04)
  • Windows Server (if required)

4. Choose Instance Type

  • Free tier: t2.micro (1 vCPU, 1GB RAM)
  • For larger workloads: t3.medium, m5.large, etc.

5. Configure Key Pair (for SSH login)

  1. Under Key pair (login) → Create new key pair.
  2. Choose RSA and .pem format.
  3. Download the .pem file → Keep it safe (required for SSH).

6. Configure Network Settings

  1. In Network settings:
    • Ensure VPC and Subnet are selected (default works).
    • Enable Auto-assign Public IP.
  2. Add Security group rules:
    • ✅ SSH (22) → For Linux (your IP only).
    • ✅ RDP (3389) → For Windows.
    • ✅ HTTP (80) → For web traffic.
    • ✅ HTTPS (443) → For SSL traffic.

7. Launch Instance

  • Click Launch Instance → AWS will provision your server.

8. Connect to Your Server

🔹 For Linux (using terminal)

chmod 400 my-key.pem   # Set correct permission
ssh -i "my-key.pem" ec2-user@<Public-IP>
Enter fullscreen mode Exit fullscreen mode

🔹 For Ubuntu AMI

ssh -i "my-key.pem" ubuntu@<Public-IP>
Enter fullscreen mode Exit fullscreen mode

🔹 For Windows

  • Download RDP file from Connect → RDP client.
  • Use Administrator password (decrypt using .pem file).

9. Install Required Software

Example: Install Nginx on Linux

sudo yum update -y
sudo yum install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx
Enter fullscreen mode Exit fullscreen mode
  • Open browser → http://<Public-IP>

10. (Optional) Elastic IP

  • Prevents IP from changing after restart:
    • EC2 Console → Elastic IPs → Allocate → Associate with instance.

✅ Your EC2 server is now ready!

Top comments (0)