Deploying a Static Website on AWS Ubuntu EC2 with Apache2

Deploying a Static Website on AWS Ubuntu EC2 with Apache2

In my journey of exploring cloud computing, I recently deployed a static website on an AWS EC2 instance running Ubuntu, using Apache2 as the web server. This hands-on project helped me strengthen my understanding of server hosting, Linux commands, and cloud infrastructure.


Requirements

  • AWS Account
  • Basic knowledge of Linux
  • Static website files (HTML, CSS, JS)


Step 1: Launch an Ubuntu EC2 Instance

  1. Log in to AWS Management Console
  2. Navigate to EC2 Dashboard > Instances
  3. Click Launch Instance
  4. Choose Ubuntu as the AMI
  5. Select an instance type (e.g., t2.micro)
  6. Create a key pair and download the .pem file
  7. Configure security group
  8. Launch the instance

Step 2: Connect to the EC2 Instance

Use your terminal to connect to the EC2 instance using SSH:

ssh -i <your-key.pem> ubuntu@<your-ec2-public-ip>        

Step 3: Update System Package

Update the package index before installing new software:

sudo apt update        

Note: On Ubuntu we use apt; for CentOS it would be dnf.

Step 4: Install Apache2

Install Apache2 using the following command:

sudo apt install apache2 -y        

Step 5: Check Apache2 Status

Verify that Apache2 is active and running:

sudo systemctl status apache2        

If it shows “active (running),” you're good to go!

Step 6: Deploy Your Website

1.Download or prepare your static HTML files.

2.If it's a ZIP file, unzip it:

unzip <your-file.zip>        

3.Navigate to the web root directory:

cd /var/www/html        

4.Optionally delete the default index.html

sudo rm index.html        

5.Copy your static files:

sudo cp -r /path-to-your-files/* /var/www/html        

Step 7: Browse Your Website

Open your browser and go to:

http://<your-ec2-public-ip>        

You should now see your live website!


Troubleshooting

  • Permission denied? Use sudo for root-level commands.
  • Apache not running? Restart with:

sudo systemctl restart apache2        

  • Website not loading? Check AWS Security Group rules and ensure ports 80/443 are allowed.


Conclusion

This was my first deployment on AWS, and it was a rewarding experience. Hosting your own website on the cloud teaches you more than theory—it gives you practical control over the full deployment stack.

Thanks for reading! 🙌

Feel free to connect with me or drop a comment if you’re trying this out too!

Connect with me:


To view or add a comment, sign in

More articles by Thisara Rupasinghe

Insights from the community

Others also viewed

Explore topics