Install an Apache web server on an Amazon EC2 instance


I was less busy and was thinking of a project to work on and thought to work on deploying a web server on Amazon EC2 instance.
You might wonder what the essence of deploying an Apache web server on an Amazon EC2 instance is. I have explained a few reasons below.
Scalability
Elasticity: EC2 instances can grow or shrink in response to the demands of your website. You can simply upgrade your EC2 plan to accommodate additional visitors or add more instances if your traffic grows.
Load Balancing: To ensure high availability and dependability, you can utilize AWS's Elastic Load Balancing (ELB) with EC2 instances to divide traffic among several Apache servers.
High Availability
- You may benefit from AWS's high availability and redundancy capabilities, such as multiple Availability Zones (AZs) and backup methods, by deploying Apache on EC2. These features help guarantee that your web server is always up and operating.
- Security
SSL/TLS Encryption: By installing SSL certificates, you may set up Apache to deliver secure HTTPS traffic, guaranteeing that all data sent between the client and the server is encrypted.
Firewalls & Security Groups: With AWS EC2 instances, you may use network access control lists (ACLs) and security groups to manage incoming and outgoing traffic. This implies that you can strictly regulate who can access your Apache server by using IP addresses or geographical locations.
- Integration with Other AWS Services
Database Integration: By combining Apache with other AWS services like RDS (Relational Database Service) or DynamoDB, you may build an entire web application stack.
S3 for Static Content: You can more efficiently store and send static content (such images, videos, etc.) by using AWS S3 rather than your EC2 instance for dynamic content.
With the flexibility and security features of AWS, Apache on an EC2 instance offers a dependable, scalable, and adaptable platform for hosting websites and web applications.
Guidelines to follow:
Step 1: Set Up AWS Account on https://aws.amazon.com, sign up/log in.
Step 2: Launch an EC2 instance. You can do this by following the tutorials on Quick Guide to Deploying a Linux EC2 Instance on AWS. All configurations have been explained in the link provided.
Step 3: Open a terminal on your computer, connect to your instance via SSH using ssh -i your-key.pem ec2-user@<Public-IP>
Step 4: Update the OS and Install Apache
sudo yum update -y
sudo yum install httpd -y
Step 5: Start and Enable Apache
sudo systemctl start httpd
sudo systemctl enable httpd
Step 6: Check status
sudo systemctl status httpd
Step 7: Allow http/https in Security Group
In the AWS Console:
Go to EC2 → Instances → Your Instance → Security → Click your Security Group → Inbound Rules.
Ensure these rules are added:
Type: HTTP | Port: 80 | Source: 0.0.0.0/0
Type: HTTPS | Port: 443 | Source: 0.0.0.0/0 (if using SSL)
(SSH is already there for access)
Step 8: Test with a Sample Web Page
echo "<h1>Hello from EC2</h1>" | sudo tee /var/www/html/index.html
Now go to http://<your-public-ip>
Step 9: Install a Web Server (Apache or Nginx)
For Amazon Linux (Apache):
sudo yum update -y
sudo yum install httpd -y
sudo systemctl start httpd
sudo systemctl enable httpd
Step 10: Add your Website Content
Replace the default page, add your customized HTML codes and save.
sudo nano /var/www/html/index.html
Thank you for stopping by and see you at my next post.
Subscribe to my newsletter
Read articles from Ms. B directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Ms. B
Ms. B
Hi, I'm a tech enthusiast who has decided to document her cloud journey as the day goes by. Stay tuned and follow me through this journey which I believe would be a wonderful experience. I'm also a team player who loves collaborating with others to create innovative solutions.