In this project, I created and deployed a web server using the AWS EC2 service. I used an Amazon Linux 2 instance, installed the Apache web server on it, and hosted a simple HTML page. I also attached an Elastic IP to keep the server's IP address fixed. Through this project, I learned how to launch and manage virtual machines on AWS and host websites on the cloud.
First, I logged in to my AWS Management Console and went to the EC2 service from the Services menu. From the EC2 Dashboard, I clicked on "Launch Instance" to start creating a virtual machine.
In the "Launch Instance" form:
- I entered the name of the instance as MyWebServer.
- I chose the Amazon Machine Image (AMI) as Amazon Linux 2 (Free tier eligible).
- For instance type , I selected t2.micro, which is free-tier eligible and perfect for small projects.
- Then, I created a new key pair and downloaded the .pem fi le to my system, which I would later use to connect via SSH.
Figure: EC2 instance setting page
In the same launch wizard, I created a new Security Group with these inbound rules:
- SSH (port 22) – so I can connect to the server from my system.
- HTTP (port 80) – so my website can be accessed through the browser.
For both ports, I allowed access from Anywhere (0.0.0.0/0) for testing purposes.
Figure: Network settings in instance
Figure: Instance running status
Once the instance was running, I copied its public IPv4 address and opened my terminal. I navigated to the folder where my .pem file was saved, then run this command to connect:
ssh -i "Your_pem_file_name.pem" ec2-user@<EC2_PUBLIC_IP>
Figure: Bash terminal use to connect EC2 via SSH
After connecting to the EC2 instance, I ran these commands one by one:
sudo yum update -y
sudo yum install httpd -y
sudo systemctl start httpd
sudo systemctl enable httpd- The first command updates the system.
- The second one installs Apache web server.
- The last two start Apache and make sure it starts automatically every time the server boots.
To keep my server’s IP address the same even after rebooting, I attached an Elastic IP:
- From the EC2 Dashboard, I clicked on Elastic IPs in the left menu.
- I clicked "Allocate Elastic IP" , then chose default settings and clicked "Allocate".
- Then I clicked "Associate Elastic IP" and selected my EC2 instance from the list.
Now, this Elastic IP was permanently linked to my server.
Figure: Elastic IP was permanently linked
I created a simple HTML page using the following command:
echo "<h1>Welcome to My Apache Web Server - Hosted on AWS EC2</h1>" | sudo tee /var/www/html/index.htmlChecked the content:
cat /var/www/html/index.htmlThen, I opened my browser and typed my Elastic IP in the address bar. The page loaded and showed my custom message. That conforrmed my web server was working! ( http://15.206.221.81 ).
Figure: Web server working in browser
Access the website at: http://<Elastic_IP>
To ensure Apache runs even if I reboot the server, I used this command again (just to be safe):
sudo systemctl enable httpdThis command makes sure that Apache starts automatically every time the instance is restarted.
Figure: Bash terminal run enable httpd command
- How to launch and configure an EC2 instance
- How to set up security groups for access
- How to connect to a cloud server using SSH
- How to install and run a web server
- How to keep a fixed IP using Elastic IP
- How to host and view a website on the cloud
This project gave me confidence to work with cloud servers and host real websites on AWS. It was a great learning experience for me as a beginner in cloud computing.
Vishwaraj Kumar
🔗 GitHub Profile
🔗 LinkedIn Profile

