🏠 Home / Hub

☁️ AWS Lesson 02 — EC2 (Virtual Servers)

← Back to AWS Menu  |  🏠 Hub

1. EC2 ဆိုတာ

EC2 = Elastic Compute Cloud = AWS ရဲ့ Virtual Server (VM)

🖥️ Windows / Linux Server ကို Cloud မှာ ငှားသုံးတာ
⚡ Minute အလိုက် ပေးရတယ် (On-Demand pricing)
📈 Traffic မြင့်ရင် scale up — နည်းရင် scale down

2. Instance Types

Familyဘာအတွက်Example
t3 / t2General purpose (web servers, dev)t2.micro (free tier)
m5 / m6Balanced memory/CPUm5.large
c5 / c6Compute optimized (CPU heavy)c5.xlarge
r5 / r6Memory optimized (databases)r5.large
p3 / g4GPU (ML, video)g4dn.xlarge
Free Tier: t2.micro (1 vCPU, 1GB RAM) — 750 hrs/month free (12 လ)

3. Launch EC2 Instance

1
EC2 → Instances → Launch Instance
2
AMI ရွေး: Ubuntu 22.04 LTS (free tier eligible)
3
Instance type: t2.micro
4
Key pair create: my-key.pem download လုပ် (safe ထားပါ!)
5
Security Group: SSH (22), HTTP (80), HTTPS (443) Allow
6
Storage: 8 GB gp3 (default)
7
Launch Instance!

4. SSH Connect

# Windows PowerShell / Mac Terminal မှာ
# key file permission fix (Mac/Linux)
chmod 400 my-key.pem

# SSH connect
ssh -i "my-key.pem" ubuntu@<your-public-ip>

# Example
ssh -i "my-key.pem" ubuntu@54.169.123.45

# Server ဝင်ပြီးရင် — update လုပ်
sudo apt update && sudo apt upgrade -y

# NGINX install
sudo apt install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx
Public IP ကို EC2 → Instances → Instance ကို click → Public IPv4 address မှာ ကြည့်
Elastic IP = Static IP (reboot ဖြစ်ရင် IP မပြောင်း) — attach လုပ်ဖို့ recommend

5. Security Groups

Security Group = Cloud Firewall (Inbound/Outbound rules)

Inbound Rules (ဝင်ခွင့်)
┌─────────────┬──────────┬───────────┬────────────────┐
│ Type        │ Protocol │ Port      │ Source         │
├─────────────┼──────────┼───────────┼────────────────┤
│ SSH         │ TCP      │ 22        │ My IP          │
│ HTTP        │ TCP      │ 80        │ 0.0.0.0/0      │
│ HTTPS       │ TCP      │ 443       │ 0.0.0.0/0      │
│ MySQL/Aurora│ TCP      │ 3306      │ Security Group │
└─────────────┴──────────┴───────────┴────────────────┘

Outbound Rules — default: All traffic allowed
⚠️ SSH (port 22) ကို "My IP" မှာပဲ ထားပါ — 0.0.0.0/0 (anywhere) မထားနဲ့ — brute force attack ဖြစ်နိုင်

6. Install LAMP Stack on EC2

# Apache + PHP + MySQL install
sudo apt update
sudo apt install apache2 php php-mysql mysql-server -y

# Apache start
sudo systemctl start apache2

# PHP test file
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php

# MySQL secure
sudo mysql_secure_installation

# Browser မှာ: http://<your-ip>/info.php

← AWS 01  |  Next: AWS 03 → S3 →

📌 Study Checklist