Install Apache Web Server On Ubuntu 20.04

Alon Shrestha » 06 Sep 2020 » linux, webhosting

Apache web server is an open source software application that activates your machine to HTTP server. This allows the machine to serve the http request recived from the user. Installing apache web server in Ubuntu is free and easy. This article provides a simple tutorial on installing apache web server in Ubuntu 20.04.

Requirements
Before following this tutorial you should have following requirements.

  • System with Ubuntu 20.04.1 LTS
  • Root Access
  • Internet Connection

Table of Content

Step 1: Installing Apache Web Server In Ubuntu

Apache web server is a default software available in Ubuntu repositories. So, we can install it with a few commands. Before installing apache first make sure your system is up to date.

$ sudo apt update

Now, install apache in your system

$ sudo apt install apache2

Step 2: Configure Your Firewall

Apache web server runs at default port 80. After apache is installed we need to allow port 80 for everyone from UFW firewall. For that, check the available ufw application list.

$ sudo ufw app list

Output:

Available applications:
  Apache
  Apache Full
  Apache Secure
  OpenSSH

Now use the below command to allow Apache.

$ sudo ufw allow 'Apache'

Output:

Rules updated
Rules updated (v6)

Verify the changes made.

$ sudo ufw status

Output:

Status: active

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

Step 3: Checking Status Of Apache Web Server

After configuring your firewall, now check the status of the server with ‘systemctl’ command.

$ sudo systemctl status apache2

Output:

 apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2020-09-06 05:53:18 UTC; 16min ago
       Docs: https://httpd.apache.org/docs/2.4/
   Main PID: 20348 (apache2)
      Tasks: 55 (limit: 1164)
     Memory: 5.2M
     CGroup: /system.slice/apache2.service
             ├─20348 /usr/sbin/apache2 -k start
             ├─20350 /usr/sbin/apache2 -k start
             └─20351 /usr/sbin/apache2 -k start

Access your web server to configure that the server is running properly from your browser. Enter the url

http://your_ip-address

If you are in your local machine enter

http://localhost or https://127.0.0.1

In my case, my machine address is http://3.89.36.46/. You will see the default Ubuntu 20.04 apache page which means your server is running properly.

How To Install Apache Web Server In Ubuntu 20.04

Step 4: Configuring Your Apache Web Server

It is important to know how to control your server system. Controlling the server system means stop, start and restart your server.

Start apache web server.

$ sudo systemctl start apache2

Stop apache web server.

$ sudo systemctl stop apache2

Restart apache web server.

$ sudo systemctl restart apache2

Enable apache web server. This makes apache to run automatically when you reboot your system.

$ sudo systemctl enable apache2

Disable apache web server. This stops apache to run automatically when you reboot your system.

$ sudo systemctl disable apache2

Summary

Hope you have learn how to install apache web server in Ubuntu 20.04.1. If you have any issue please let me know through comment secetion below.