This README provides detailed steps on how to deploy a static website on an AWS EC2 instance using Apache.
- Introduction
- Prerequisites
- Setup AWS EC2 Instance
- Install and Configure Apache
- Deploy the Static Website
- Access the Website
- Conclusion
This guide will walk you through the process of deploying a static website on an AWS EC2 instance using Apache. The static website includes an HTML file hosted on GitHub. The website will mention the HNG Internship and contain a link to https://hng.tech.
- An AWS account
- Basic knowledge of AWS EC2 and SSH
- An SSH key pair for accessing the EC2 instance
- A static website (HTML, CSS, JavaScript files)
-
Launch an EC2 Instance:
- Log in to your AWS Management Console.
- Navigate to EC2 Dashboard.
- Click on "Launch Instance".
- Choose an Amazon Machine Image (AMI) (e.g., Amazon Linux 2 AMI).
- Select an Instance Type (e.g., t2.micro for free tier eligibility).
- Configure Instance Details (default settings are usually fine).
- Add Storage (default settings are fine).
- Add Tags (optional).
- Configure Security Group:
- Add a rule to allow HTTP traffic on port 80.
- Add a rule to allow SSH traffic on port 22.
- Review and Launch the instance.
- Select your SSH key pair for the instance.
-
Connect to the EC2 Instance:
- Open a terminal (or use PuTTY if on Windows).
- Connect to your instance using SSH:
ssh -i /path/to/your-key-pair.pem ec2-user@your-instance-public-ip
-
Update Packages:
sudo yum update -y
-
Install Apache:
sudo yum install httpd -y
-
Start Apache:
sudo systemctl start httpd
-
Enable Apache to Start on Boot:
sudo systemctl enable httpd
-
Navigate to the Apache Directory:
cd /var/www/html
-
Download the
index.html
File Usingwget
:sudo wget https://raw.githubusercontent.com/AugustHottie/devops-task0/master/index.html
-
Set the Correct Permissions:
sudo chown apache:apache /var/www/html/index.html sudo chmod 644 /var/www/html/index.html
- Open a Web Browser:
- Navigate to the public IP address of your EC2 instance. Your static website should be displayed.
By following the steps outlined in this guide, you have successfully deployed a static website on an AWS EC2 instance using Apache. Your website should now be accessible via the public IP address of your EC2 instance.