What this is
This guide shows how to install and run the Apache web server on the most common Linux families.
What it is for
- Host websites and web applications
- Serve static files and reverse proxy (in some setups)
Prerequisites
- SSH access + sudo
- A domain (optional) or just use the server IP
Step-by-step by distribution
A) Ubuntu/Debian
A1) Install Apache
sudo apt update
sudo apt install -y apache2
A2) Enable and start
sudo systemctl enable --now apache2
A3) Open firewall (if UFW)
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw status
A4) Verify service
sudo systemctl status apache2 --no-pager
B) CentOS/RHEL/Rocky/AlmaLinux
B1) Install Apache (httpd)
sudo dnf install -y httpd
B2) Enable and start
sudo systemctl enable --now httpd
B3) Open firewall (firewalld)
sudo firewall-cmd --add-service=http --permanent
sudo firewall-cmd --add-service=https --permanent
sudo firewall-cmd --reload
B4) Verify service
sudo systemctl status httpd --no-pager
Final verification
From your browser:
http://YOUR_SERVER_IP
Or from the server:
curl -I http://127.0.0.1
Warnings & notes
- Apache service name is
apache2on Ubuntu/Debian andhttpdon RHEL-based.
Conclusion
Apache is installed and serving traffic. Next steps are creating virtual hosts and enabling HTTPS.