Updated: 11 October 2026 · Applies to: Ubuntu 24.04, Debian 12, AlmaLinux 9 and Rocky Linux 9

Apache HTTP Server is one of the most widely used web servers. This beginner's guide covers installing it and the main configuration files on current systems.

Install

apt install apache2                                   # Ubuntu / Debian
dnf install httpd && systemctl enable --now httpd    # AlmaLinux / Rocky

Open the firewall

ufw allow 80,443/tcp                                   # Ubuntu / Debian with UFW
firewall-cmd --permanent --add-service=http --add-service=https && firewall-cmd --reload   # AlmaLinux / Rocky

Where things are

  • Main configuration: /etc/apache2/apache2.conf (Ubuntu/Debian) or /etc/httpd/conf/httpd.conf (AlmaLinux/Rocky).
  • Sites: /etc/apache2/sites-available/ enabled with a2ensite, or /etc/httpd/conf.d/*.conf.
  • Default web root: /var/www/html.
  • Logs: /var/log/apache2/ or /var/log/httpd/.

Everyday commands

apachectl configtest            # check the configuration
systemctl reload apache2         # httpd on AlmaLinux/Rocky
a2enmod rewrite headers ssl      # enable modules (Ubuntu/Debian)

Create the Apache site

Create /etc/apache2/sites-available/example.com.conf (Ubuntu/Debian) or /etc/httpd/conf.d/example.com.conf (AlmaLinux/Rocky):

<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com
    <Directory /var/www/example.com>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Ubuntu/Debian: a2ensite example.com && a2enmod rewrite && systemctl reload apache2. AlmaLinux/Rocky: apachectl configtest && systemctl reload httpd.

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Managed dedicated servers

our engineers look after the server for you, from $135 a month.

Was this answer helpful?

Still stuck? Open a ticket