Installing an Apache Web Server on Ubuntu

Destany Parria
Nerd For Tech
Published in
3 min readJan 23, 2023

Introduction

Today we will walk through a simple way to install an Apache Web Server on a Linux Ubuntu 18.04 LTS Server. Just as Ubuntu can be translated as “I am because we are”, we will go through each step together while you follow along! I recommend practicing the commands after creating an SSH connection to the servers offered by A Cloud Guru. This will avoid the potential of damaging your device if any errors are made. But first, lets review what Apache and Ubuntu are:

Apache: The most widely used webserver software and runs on 67% of all websites in the world. Developed and maintained by Apache Software Foundation, Apache is open source software and available for free. It’s fast, reliable, and secure. And Apache can be highly customized to meet the needs of many different environments by using extensions and modules. (Source)

Ubuntu: A Debian-based distribution, often considered the best distribution if you are new to the Linux system. Ubuntu has widespread use in personal and desktop systems but is also used in servers across the internet. (Source)

Prerequisites

  • Reliable internet.
  • A device with Command Line Interface. Mac has this built into their system as Terminal, and it can be found by typing Command + Space to search and then access it. I would recommend using PowerShell for Microsoft Windows, which can be found at the link provided here: Power Shell Link.
  • Access to an account with sudo privileges.
  • A server with Ubuntu 18.04 LTS installed.

Step 1: SSH to the cloud server

SSH is the “secure shell” command that allows us to establish a connection to the Ubuntu 18.04 LTS cloud server. Use the following command:

ssh user_name@host_ip_address

Step 2: Update all packages on the server

We need to check that all packages on the server are updated prior to installation. Having the most updated version of these packages will ensure that the server will function properly and have the ability to prevent the continuously evolving security threats. Run the following command to check for packages that need to be updated:

sudo apt update

The command line will then prompt us to add our user_name password. After we enter the password, we will be given information showing which packages need to be updated.

It says that 4 packages can be upgraded.

We will now update those 4 packages on the server. Run the following command:

sudo apt upgrade

We will then get a prompt from the command line asking if we would like to continue with the update. Type Y and Enter to continue with the update.

Step 3: Install an Apache HTTP Web Server

Here we go! We’re now going to run the following command to install Apache:

sudo apt install apache2

Again, we will get a prompt from the command line asking if we would like to continue with the update. Type Y and Enter to continue with the update.

Step 4: Enable Apache for it to start

Although it is installed, we need to manually start the service and then we will check the status of it to ensure that its working properly. Enter the following command to enable Apache to start:

systemctl start apache2

Then, we will enter the following command to check the status of the server:

systemctl status apache2
We can see above that it shows the Apache is active.

Step 5: Test the Web Page

Let’s test our web page by using the Public IP Address in the web browser!

Congratulations! You now have an active server!

--

--

Destany Parria
Nerd For Tech

DevOps Engineer that enjoys working with cloud tools and technologies. Follow me on LinkedIn: https://www.linkedin.com/in/destanyparria/