💡Setup Apache Web server in AWS EC2 and Host a Simple Static Website

💡Setup Apache Web server in AWS EC2 and Host a Simple Static Website

⭐What is Apache?

Apache HTTP Server is a free and open-source web server that delivers web content through the internet. It is commonly referred to as Apache and after development, it quickly became the most popular HTTP client on the web.


⭐How to setup Apache in Ec2 Instance (Ubuntu) -

This process is fairly quick and simple so let’s get started…

🔸 First We will need an EC2 Instance. The AMI will be "ubuntu" and t2.micro will be enough for our use case.


🔸 Then Go to the Security Group of the EC2 Instance. Edit the Inbound rule and add HTTP and HTTPS with anywhere IPV4 or My IP.

Article content

🔸 Now Connect the Instance with SSH.


🔸 Update your VM.

sudo apt update        


🔸 Then Install Apache 2.

sudo apt install apache2        
Article content


🔸 After Installing Apache2. Always Make sure that Apache is properly Installed by-

apache2 -version        
Article content

🔸 Start the Apache2 service and check the status.

 sudo systemctl start apache2
sudo systemctl status apache2        
Article content


🔸 Then Go to this directory.

" /etc/apache2/sites-available"        
Article content


🔸 Then "ls" and got to the

 "000-default.conf"        

🔸 Edit the Vim File and add this Instead.

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot "/var/www/html"
    ServerName your-domain.com
    ServerAlias www.your-domain.com
    ErrorLog "/var/log/httpd/your-domain.com-error_log"
    CustomLog "/var/log/httpd/your-domain.com-access_log" common

    <Directory "/var/www/html">
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>
</VirtualHost>        


🔸Just Change the "ServerName" and "SeverAlias" to your Public IP of EC2 Instance.


🔸 Then Run the command -

sudo a2ensite 000-default.conf        
Article content


🔸After that Go back to home and Go to this Directory.

"/var/www/html"        
Article content


🔸 You will find an index.html file edit this according to your liking or you can take the code of any static website from Github and Paste it there. I add my static website code, you can use it to practice.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My Static Website</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background-color: #f4f4f4;
        }
        .container {
            text-align: center;
            background: white;
            padding: 2rem;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }
        h1 {
            color: #333;
        }
        p {
            color: #666;
        }
        a {
            color: #3498db;
            text-decoration: none;
        }
        a:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>Welcome to My Website</h1>
        <p>This is a simple static website hosted on an Apache web server.</p>
        <p>
            To learn more about hosting websites on AWS, visit
            <a href="https://aws.amazon.com/getting-started/" target="_blank">AWS Getting Started</a>.
        </p>
    </div>
</body>
</html>        


🔸 Now go to your browser and put the public IP of your EC2 instance and your Static website is running through Apache Server.

Article content





To view or add a comment, sign in

More articles by Subhojyoti Das

  • Deploying Amazon Prime CloneUsing Jenkins, Terraform, and AWS

    In this project, we successfully deployed an Amazon Prime Video clone application by leveraging AWS, Jenkins…

  • 💡Getting Started with Microsoft IIS Server

    ⭐What is an IIS server? ✅IIS (Internet Information Services) is a web server designed for hosting websites and…

    2 Comments
  • Project 6 - Azure DevOps CI/CD Pipeline Project (AKS)

    GitHub Repo -https://github.com/SubhojyotiDas3/2048-game-cicd-project-4 Step 1 - Setup Azure DevOps Now you can go to…

    2 Comments
  • Deep Dive into K9S

    K9s is a terminal-based user interface that provides a real-time view of your Kubernetes cluster. It simplifies…

  • Project 5 - CI-CD pipeline Deployed in Kubernetes

    Today we will create a CI-CD pipeline using GitHub, Jenkins, Kubernetes, and Docker. Git Repo- https://github.

  • Project 4 - Jenkins CI-CD pipeline using GitHub Webhooks

    Today we will create a CI-CD pipeline using GitHub, Jenkins, Ansible and Docker. We will push the code to GitHub, from…

  • 💡Terraform for devOps

    ⭐What is Terraform? ✅ Terraform is an infrastructure as code (IaC) tool created by HashiCorp, designed to simplify and…

    1 Comment
  • 💡Deep Dive into AWS Migration

    ⭐What is AWS Cloud Adoption Framework? ✅AWS Cloud Adoption Framework organizes guidance into six areas of focus, called…

  • 💡Deep Dive into AWS Pricing & Support

    ⭐What is AWS Free Tier ? ✅The AWS Free Tier enables you to begin using certain services without having to worry about…

  • 💡Deep Dive into AWS Monitoring and Analytics

    ⭐What is Monitoring? ✅The idea of observing systems, collecting metrics, evaluating those metrics over time, and then…

Explore content categories