Installing Apache2 Web Server and Host a Static Website on AWS EC2


This Blog contains step-by-step instructions for installing an Apache2 web server on an EC2 instance updating, installing, configuring security groups, and accessing via the public IP.
Prerequisites:-
Before we get started, ensure you have the following:
An active AWS account
(Optional )A basic understanding of EC2, security groups, and static websites.
Steps to Launch and connect to an EC2 Instance.
You need to create an EC2 instance. For Detailed steps Click here
Steps for Hosting a Static Website on AWS EC2.
Log in to the EC2 Linux instance by connecting through AWS default EC2 instance connect.
- Use sudo to switch from ubuntu to root for administrative tasks on EC2 Instance to mitigate the risk of unintended alterations affecting system stability or security.
Type sudo su to switch from ubuntu to root; followed by pressing Enter
- After sudo-ing to the root user execute the command apt update followed by pressing Enter to install any pending updates
- Execute the command apt install apache2 -y followed by pressing Enter to install the apache2 web server on the Ubuntu Instance
Start Apache: Execute the command systemctl start apache2 followed by pressing Enter
Enable Apache to start on boot:
Execute command systemctl enable apache2 followed by pressing Enter.
Execute command systemctl status apache2 followed by pressing Enter.
Use this command echo "It works" > /var/www/html/index.html to create the HTML file.
Test Your Website
Now that everything is set up, open a web browser(chrome) and visit your EC2 instance’s public IP (e.g.,
http://your-public-ip
). If everything is configured correctly, your static website should appear.In this Case http://34.227.143.10.
Congratulations on Installing and hosting static website an Apache2 Web Server on EC2! Good job!
Subscribe to my newsletter
Read articles from Iqbal Shaikh directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
