Introduction
Want to get your web app live without the headache of complicated cloud setups? You're not alone. Many developers and startups face hurdles when trying to launch a simple web server. The good news? With Amazon EC2 and Ubuntu 24.04 LTS, you can deploy an Apache web server quickly and efficiently.
In this hands-on guide, you’ll learn exactly how to spin up an EC2 instance, configure Ubuntu, and install Apache—without wasting hours on trial and error. Whether you’re hosting a portfolio, blog, or backend app, this tutorial will get you there fast.
Let’s dive in!
Why Use Amazon EC2 and Apache on Ubuntu 24.04?
What is Amazon EC2?
Amazon Elastic Compute Cloud (EC2) is a part of AWS (Amazon Web Services) that lets you rent virtual servers—called instances—to run your applications.
Why developers love EC2:
- Scalability on demand
- Cost-effective pay-as-you-go pricing
- Wide choice of operating systems and instance types
- Deep integration with the AWS ecosystem
Why Apache and Ubuntu 24.04 LTS?
- Apache is the most widely used web server globally. It’s free, stable, and battle-tested.
- Ubuntu 24.04 LTS is the latest Long-Term Support release, offering performance and security updates through 2029.
This combo is ideal for developers who want control, flexibility, and security.
Prerequisites
Before we begin, make sure you have:
- An active AWS account
- Basic familiarity with terminal commands
- A modern browser and SSH client (or use terminal on macOS/Linux)
Step 1: Launch Your Amazon EC2 Instance
1.1 Log in to AWS Console
Go to aws.amazon.com and log in. Navigate to EC2 Dashboard.
1.2 Click “Launch Instance”
-
Name: Call it something like
MyApacheServer
-
AMI: Choose "Ubuntu Server 24.04 LTS (HVM), SSD Volume Type"
-
Instance Type:
t2.micro
(free tier eligible) -
Key Pair: Create a new one or use an existing one
-
Security Group Settings:
- Allow SSH (port 22) from your IP
- Allow HTTP (port 80) from anywhere
Click Launch Instance.
1.3 Connect to Your Instance via SSH
Wait until the instance is running, then click Connect > SSH and follow the terminal instructions:
ssh -i your-key.pem ubuntu@your-ec2-public-dns
Step 2: Update Ubuntu and Install Apache
2.1 Update System Packages
Once you're connected to your instance:
sudo apt update && sudo apt upgrade -y
2.2 Install Apache
sudo apt install apache2 -y
2.3 Enable and Start Apache
sudo systemctl enable apache2
sudo systemctl start apache2
2.4 Check Your Web Server
Go to your EC2 instance's public IP in a browser:
http://your-ec2-public-ip
You should see the Apache2 Ubuntu Default Page!
Step 3: Configure Apache for Your Website
3.1 Set Up Directory Structure
sudo mkdir -p /var/www/mywebsite/html
sudo chown -R $USER:$USER /var/www/mywebsite/html
3.2 Create an Example HTML File
echo "<h1>Hello from Apache on EC2!</h1>" > /var/www/mywebsite/html/index.html
3.3 Create a Virtual Host File
sudo nano /etc/apache2/sites-available/mywebsite.conf
Paste in the following:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/mywebsite/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
3.4 Enable the Site and Reload Apache
sudo a2ensite mywebsite.conf
sudo a2dissite 000-default.conf
sudo systemctl reload apache2
Step 4: Set Up a Custom Domain (Optional but Recommended)
4.1 Purchase a Domain
You can use domain providers like Namecheap, GoDaddy, or AWS Route 53.
4.2 Point Domain to EC2
Set an A
record in your DNS settings to your EC2 instance's public IP address.
4.3 Test It
After propagation (may take a few minutes to a few hours), visit:
http://yourdomain.com
You should see your Apache welcome page or custom HTML.
Step 5: Secure Your Server (HTTPS with SSL/TLS)
5.1 Install Certbot and Dependencies
sudo apt install certbot python3-certbot-apache -y
5.2 Request and Install a Free SSL Certificate
sudo certbot --apache
Follow the on-screen instructions. Certbot will automatically configure your Apache virtual host file.
5.3 Test Auto-Renewal
sudo certbot renew --dry-run
Bullet Points / Quick Takeaways
- EC2 offers scalable, pay-as-you-go cloud hosting
- Ubuntu 24.04 LTS is stable and secure for long-term use
- Apache is free, fast, and widely supported
- You can go from zero to live site in under 30 minutes
- Secure your site with HTTPS using Certbot
- Add a domain for a professional appearance
Call to Action (CTA)
Ready to deploy your next project? Sign up for AWS and follow this guide to launch your Apache-powered web server today.
Or, if you want expert help, contact our cloud deployment team for a stress-free setup.
FAQ Section
Q: Is EC2 free to use?
A: The AWS Free Tier includes 750 hours/month of t2.micro
instances for 12 months. Perfect for beginners and testing.
Q: Can I install other web servers like Nginx instead of Apache? A: Absolutely. The process is similar. Choose what best fits your project.
Q: How do I access my files after deployment?
A: You can use scp
, SFTP tools like FileZilla, or push via Git from a local repo.
Q: What happens if I stop the EC2 instance? A: The instance will shut down, and your site will go offline. Data remains if you restart it.
Q: Can I automate this deployment? A: Yes! Use infrastructure-as-code tools like Terraform or AWS CloudFormation for automation.