Ravindra BagaleCourses & study guides

Chapter 7: Static Website Hosting (3 OSes × 2 Web Servers)

7.3 Step 1 (common): create the sample website

Now open your terminal and try this with me. Run this on the server (it creates ~/mysite with an index.html, a CSS file and a custom 404 page):

mkdir -p ~/mysite/css
cat > ~/mysite/index.html <<'EOF'
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>My First Cloud Website</title>
  <link rel="stylesheet" href="css/style.css">
</head>
<body>
  <header><h1>Namaste from AWS EC2!</h1></header>
  <main>
    <p>This static website is served by a web server running on an EC2 instance.</p>
    <ul>
      <li>Cloud: Amazon Web Services</li>
      <li>Server: EC2 in the Mumbai region</li>
      <li>Content: HTML + CSS</li>
    </ul>
  </main>
  <footer>Hosted as part of the AWS Hands-On Handbook lab</footer>
</body>
</html>
EOF
cat > ~/mysite/css/style.css <<'EOF'
body   { font-family: Arial, sans-serif; margin: 0; background: #f4f7fb; color: #222; }
header { background: #0b3d6e; color: #fff; padding: 20px; text-align: center; }
main   { max-width: 700px; margin: 30px auto; background: #fff; padding: 20px; border-radius: 8px; }
footer { text-align: center; color: #777; padding: 20px; }
EOF
cat > ~/mysite/404.html <<'EOF'
<!DOCTYPE html><html><body><h1>404 - Page not found</h1><a href="/">Go home</a></body></html>
EOF
ls -R ~/mysite