Installing Apache from the distribution packages gives Ubuntu or Debian hosts a supported web server for static sites, reverse proxies, and application front ends. Using the packaged build keeps updates, log paths, and helper commands aligned with the operating system so later tasks such as adding virtual hosts or enabling HTTPS stay predictable.

On both distributions, the web server is delivered by the apache2 package and managed by the systemd unit apache2.service. The packaged layout keeps global settings in /etc/apache2/apache2.conf, the default site in /etc/apache2/sites-available/000-default.conf, enabled sites in /etc/apache2/sites-enabled, and follow-on helpers such as a2enmod and a2ensite for module and site management.

A successful install ends with three checks: apache2ctl configtest reports Syntax OK, systemd shows the service running, and a local request to http://127.0.0.1/ returns 200 OK. On many hosts the package post-install step starts Apache automatically, while the common AH00558 warning only means a global ServerName is not set yet. Remote clients also need port 80 allowed through the active firewall before they can reach the default page.

Steps to install Apache on Ubuntu or Debian:

  1. Open a terminal with sudo privileges.
  2. Refresh the package index.
    $ sudo apt update
  3. Install the Apache package.
    $ sudo apt install --assume-yes apache2

    The package also installs apache2ctl, a2enmod, and a2ensite, keeps the default site in /etc/apache2/sites-available/000-default.conf, and serves the packaged landing page from /var/www/html.

  4. Test the packaged configuration before changing anything.
    $ sudo apache2ctl configtest
    AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 192.0.2.10. Set the 'ServerName' directive globally to suppress this message
    Syntax OK

    The AH00558 line is a hostname warning, not an install failure. Syntax OK confirms the packaged configuration parsed successfully.

  5. Enable Apache at boot and start it now.
    $ sudo systemctl enable --now apache2

    If the package already started the service during installation, this command still makes the boot state explicit.

  6. Confirm the service is active in systemd.
    $ sudo systemctl is-active apache2
    active

    If the unit is not active, inspect sudo journalctl -u apache2 and /var/log/apache2/error.log before retrying.

  7. Verify the default site responds on localhost.
    $ curl --head http://127.0.0.1/
    HTTP/1.1 200 OK
    ##### snipped #####

    A 200 OK response proves the default virtual host is listening on port 80 and serving content from the packaged web root.

  8. Allow inbound HTTP traffic if remote clients should reach the server.
    $ sudo ufw allow Apache

    Current Ubuntu packages install the Apache, Apache Secure, and Apache Full UFW profiles. On Debian or on hosts that use nftables, iptables, or cloud firewalls instead of UFW, apply the equivalent rule in the active firewall stack.