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)