How To Install the Apache Web Server on Ubuntu 18.04?

Step 1 — Installing Apache

Updating the local package index to reflect the latest upstream changes:

sudo apt update

Then, install the apache2 package:

sudo apt install apache2


Step 2 — Adjusting the Firewall

List the ufw application profiles by typing:

sudo ufw app list

You will see a list of the application profiles:

Available applications: 
Apache Full 
Apache Secure 

As you can see, there are three profiles available for Apache:

  • Apache: This profile opens only port 80 (normal, unencrypted web traffic)
  • Apache Full: This profile opens both port 80 (normal, unencrypted web traffic) and port 443 (TLS/SSL encrypted traffic)
  • Apache Secure: This profile opens only port 443 (TLS/SSL encrypted traffic)

It is recommended that you enable the most restrictive profile that will still allow the traffic you've configured. Since we haven't configured SSL for our server yet in this guide, we will only need to allow traffic on port 80:

sudo ufw allow 'Apache'

You can verify the change by typing:

sudo ufw status


Step 3 — Checking your Web Server Status

Check with the systemd init system to make sure the service is running by typing:

sudo systemctl status apache2