Getting Apache Running on Your Ubuntu Server
If you’re setting up a web server, Apache is often the first choice and for good reason. It’s stable, well-documented, and works well on Ubuntu. In this guide, We’ll walk you through how to install Apache on Ubuntu, verify it’s running, and apply a few practical configuration and security tweaks. This tutorial is aimed at beginners and intermediate users running Ubuntu on a VPS, cloud instance, or dedicated server.
The goal is simple: get Apache up and running cleanly, without unnecessary complexity.
What You’ll Need
Before you install Apache on Ubuntu, make sure you have:
- A fresh Ubuntu 22.04 or 24.04 LTS server (VPS, cloud, or dedicated)
- SSH access with a sudo-enabled user
- About 50MB of free disk space
- A basic understanding of Linux command line
Step-by-Step: Install Apache on Ubuntu
Fire up your terminal and let’s get started.
1. Update Your Package Index
It’s always a good habit to update your package index first:
sudo apt update && sudo apt upgrade -y
This ensures you’re pulling the latest update from Ubuntu’s repositories and patches any security vulnerabilities.
2. Install Apache Package
sudo apt install apache2 -y
The -y flag automatically confirms the installation.
3. Verify Apache Status
Check the service status:
sudo systemctl status apache2
You should see “active (running)” in green. If not, start it manually:
sudo systemctl start apache2
sudo systemctl enable apache2
The enable command make apache start automatically every boot.
4. Allow Apache Through the Firewall
If you’re using UFW (common on Ubuntu), allow HTTP traffic:
sudo ufw allow 'Apache Full'
sudo ufw reload
This opens ports 80 (HTTP) and 443 (HTTPS).
You can confirm the rule with:
sudo ufw status
5. Test Apache in a Browser
Open your browser and visit your server’s IP address:
http://your_server_ip
If you see the Apache default page, the installation was successful.
Common Pitfalls
- Forgetting firewall rules: Your Apache install apache setup won’t be accessible if ports are blocked
- Not enabling the service: Server reboots will leave Apache offline
- Skipping updates: Always apt update before installing packages
- Use virtual hosts instead of editing the default site directly
- Enable HTTPS early (Let’s Encrypt works great with Apache)
- Restart Apache after config changes:
sudo systemctl reload apache2
FAQ: Install Apache on Ubuntu
Q: Is Apache free to use?
A: Yes. Apache is open-source and free for both personal and commercial use.
Q: What’s the difference between Apache and Nginx?
A: Apache is process-based and very flexible; Nginx is event-driven and often faster for high concurrency.
Q: Where are Apache logs stored?
A: Access and error logs are located in /var/log/apache2/.
Q: Do I need a firewall to run Apache?
A: It’s strongly recommended. UFW is simple and effective on Ubuntu.
Q: Can I run Apache alongside Nginx?
A: Yes, but they need different ports. Apache typically uses 80; configure one to use 8080 or another port.
Wrapping Up
That’s it! You’ve successfully installed Apache on Ubuntu and got your web server running. From here, you can configure virtual hosts, install SSL certificates, or start deploying your applications. The beauty of Apache is its flexibility. Start simple, then customize as your needs grow.