How To Install and Setup the Apache Web Server on Ubuntu 18.04

Gouse Mohiddin
2 min readJan 23, 2021

Intro

The Apache HTTP server is the most widely-used web server in the world. It provides many powerful features including dynamically loadable modules, robust media support, and extensive integration with other popular software.

In this guide, I’ll explain how to install an Apache web server on your Ubuntu 18.04 server.

Step 1 — Install Apache

In Ubuntu’s default software repositories, Apache is open, enabling it to be installed using traditional package management tools.

use the following command to check for any updates

$ sudo apt update

Then use the following command to install apache2 package

$ sudo apt install apache2

After the confirmation, apt will install Apache and all other required dependencies.

Step 2 — Firewall Adjustments

To begin testing Apache, we must modify the firewall settings to allow outside access to the default web ports. You need to enable ufw , Apache will register few application with ufw at the time of installation.

  • 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)

You can check these with the following command

$ sudo ufw list

Now, you need to enable only those which need external access, If you have SSL then you can allow port 443 too. Let’s enable only port 80 for now. using

$ sudo ufw allow 'Apache'

verify it by typing

$ sudo ufw status

You should see HTTP traffic allowed in the displayed output:

Output
Status: active

To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
Apache ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
Apache (v6) ALLOW Anywhere (v6)

Yay! the profile has been activated to allow access to the web server.

Happy Coding!

--

--