Install Apache
On Ubuntu and Debian:
sudo apt update
sudo apt install apache2The service starts right away and is enabled at boot. On AlmaLinux and Rocky Linux the package is called httpd, and you start it yourself:
sudo dnf install httpd
sudo systemctl enable --now httpdCheck the version with apache2ctl -v on Debian and Ubuntu or httpd -v on AlmaLinux and Rocky Linux. All current releases ship Apache 2.4, and both families use the event MPM by default.
Open the Firewall
Web traffic uses port 80 for HTTP and 443 for HTTPS. If ufw is active on Ubuntu or Debian:
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw statusIf ufw is not enabled yet, allow SSH first with sudo ufw allow OpenSSH (or your custom SSH port) before you run sudo ufw enable, or the firewall cuts off your session. On AlmaLinux and Rocky Linux, firewalld is active by default:
sudo firewall-cmd --permanent --add-service=http --add-service=https
sudo firewall-cmd --reloadIf your provider has a firewall in front of the server, open the same two ports there.
Check That It Runs
systemctl status apache2 # Debian and Ubuntu
systemctl status httpd # AlmaLinux and Rocky Linux
curl -I http://localhostThe status should read active (running), and curl should print an HTTP status line. Then open http://203.0.113.10, with your server's IP address, in a browser. Ubuntu and Debian show the Apache default page, a file at /var/www/html/index.html that you can replace. AlmaLinux and Rocky Linux show a test page while /var/www/html has no index file; the package's welcome.conf sends it with a 403 status, which is expected, and it disappears as soon as you add an index file.
Where the Files Are
| Item | Debian and Ubuntu | AlmaLinux and Rocky Linux |
|---|---|---|
| Main file | /etc/ | /etc/ |
| Sites | /etc/ | /etc/ |
| Modules | /etc/ | /etc/ |
| Logs | /var/ | /var/ |
| Web root | /var/ | /var/ |
| Service user | www- | apache |
Debian and Ubuntu split the configuration into small files and switch them on with symbolic links: a2ensite and a2dissite for sites, a2enmod and a2dismod for modules, a2enconf and a2disconf for extra settings. The ports Apache listens on are in /etc/apache2/ports.conf. AlmaLinux and Rocky Linux have no such tools: Apache reads every file ending in .conf in /etc/httpd/conf.d/, modules are loaded by LoadModule lines in /etc/httpd/conf.modules.d/, and the Listen lines are in httpd.conf.
Test Before Every Reload
After any change, check the syntax first. A valid configuration prints Syntax OK:
sudo apachectl configtest
sudo systemctl reload apache2 # or: sudo systemctl reload httpdA reload re-reads the configuration while running requests finish, so visitors notice nothing. A restart drops every open connection, and if the new configuration is broken, Apache stays down. The details are in how to start, stop, and restart Apache.
SELinux on AlmaLinux and Rocky Linux
SELinux is enforcing on these systems and should stay that way. Files under /var/www get the right label automatically. If you keep a site elsewhere, for example in /srv/example.com, label it for Apache:
sudo semanage fcontext -a -t httpd_sys_content_t "/srv/example.com(/.*)?"
sudo restorecon -Rv /srv/example.comWithout the label, Apache answers 403 Forbidden even when the file permissions are correct. The semanage command is in the policycoreutils-python-utils package.
Add HTTPS
On AlmaLinux and Rocky Linux, install the TLS module with sudo dnf install mod_. On Debian and Ubuntu it ships with apache2 and is switched on with sudo a2enmod ssl. Then get a certificate as shown in Certbot Apache.
Next Steps
- Several sites on one server: see how to set up Apache virtual hosts.
- PHP and a database: see how to install a LAMP stack on Ubuntu.
- Logs: see how to read Apache access and error logs.
Updated:
Linux VPS with Full Root Access
MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.
More Guides
No Limits on Service or Support
You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

- 100% customer satisfaction goal
- Our own hardware
- 24/7 ticket and email support
- 4 countries with locations