เลือกฟอนต์:

ข้อที่ 2 การใช้งาน EC2 Instance พร้อมกำหนด User Data เพื่อติดตั้ง Apache Web Server และแสดงผลหน้าเว็บด้วยข้อความ HTML ผ่าน Web Browser


🧠 เป้าหมาย


🧰 บริการที่เกี่ยวข้อง


🛠️ ขั้นตอนการทำ

1. เตรียม Script User Data

แก้ xxxx กับ yyyy ตามโจทย์:

#!/bin/bash
yum update -y
yum install -y httpd
systemctl enable httpd
systemctl start httpd
echo "<center><h1>This is xxxx instance with the code yyyy that runs the Apache Webserver!</h1></center>" > /var/www/html/index.html

2. เปิดใช้งาน EC2 Instance

  1. ไปที่ EC2 Dashboard > Launch Instance

  2. กำหนดค่า:

    • Name: ec2xxxxyyyy
    • AMI: Amazon Linux 2023 AMI
    • Instance Type: t2.micro
    • Key Pair: เลือก key เดิมหรือสร้างใหม่
  3. ในหัวข้อ Advanced Details > User data:

    • วาง script ด้านบน (ต้องเริ่มด้วย #!/bin/bash)
  4. ใน Network settings:

    • ติ๊ก Allow HTTPS traffic from the internet`
    • ติ๊ก Allow HTTP traffic from the internet
  5. คลิก Launch Instance

3. ตรวจสอบผลลัพธ์

4. เปิดเว็บใน Browser


📸 สิ่งที่ต้องแคปส่ง

รวมทุกอย่างไว้ใน รูปเดียว ให้เห็น:

  1. หน้า EC2 Instance Summary (ชื่อ, ประเภท, Public IPv4 DNS)
  2. Script User Data (สคริปต์ที่ใช้จริง)
  3. หน้าเว็บใน Chrome ที่แสดงข้อความ พร้อม URL ชัดเจนในช่อง address bar

ตัวอย่างรูปภาพที่ต้องส่ง

Example Image 2