Google Cloud Compute Engine

How to Install Apache on Ubuntu 20.04 – Google Cloud

Disclosure: This post may contain affiliate links, which means we may receive a commission if you click a link and purchase something that we recommended.

Pinterest LinkedIn Tumblr

How to Install Apache on Ubuntu 20.04 – Google Cloud. Apache is the most widely used HTTP web server which provides dynamic loading modules, easily integrating with other applications.

In this guide you are going to learn how to install Apache2 on Ubuntu 20.04 and configure Firewall.

This setup is tested on Google Cloud so you can try this setup on any cloud servers like AWS, Azure or any VPS or dedicated servers.


  1. Your Compute Engine Instance running.
  2. For setting up Compute Engine, see the Setting up Compute Engine Instance with Ubuntu 20.04.

Install Apache

Let’s start by updating the local package index with the following command.

sudo apt update
sudo apt upgrade

Install Apache 2 package from the Ubuntu repository.

sudo apt install apache2

This will install apache2 and all required dependencies.

Configure Firewall

Now you can set up Uncomplicated Firewall (UFW) with Apache to allow public access on default web ports for HTTP and HTTPS

sudo ufw app list

You will see all listed applications.

Available applications:
Apache Full
Apache Secure
  • Apache: This profile opens 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)
  • OpenSSH: This profile opens port 22 for SSH access.

If you are not going to use SSL you need to enable only the Apache profile.

Now we will enable Apache Full.

sudo ufw allow 'Apache Full'

With this command you can view the status of UFW.

sudo ufw status

You will see the output as follows.

Status: active
To Action From
-- ------ ----
Apache Full ALLOW Anywhere
OpenSSH ALLOW Anywhere
Apache Full (v6) ALLOW Anywhere (v6)
OpenSSH (v6) ALLOW Anywhere (v6)

Check Apache Installation

Once Apache is installed is is started automatically and already be up and running.

Every process in Apache is managed with the systemctl or service command. Check the status of Apache with the following command.

sudo systemctl status apache2
apache2.service - The Apache HTTP Server
      Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
      Active: active (running) since Tue 2020-04-28 09:19:39 UTC; 14s ago
    Main PID: 2913 (apache2)
       Tasks: 55 (limit: 682)
      Memory: 5.5M
      CGroup: /system.slice/apache2.service
              ├─2913 /usr/sbin/apache2 -k start
              ├─2915 /usr/sbin/apache2 -k start
              └─2916 /usr/sbin/apache2 -k start

Now if you check the External IP address of your VM instance, you will see the default Apache welcome page.

Apache welcome page

Common Apache Commands

To start Apache web server.

sudo systemctl start apache2

To stop Apache webserver.

sudo systemctl stop apache2

To restart Apache web server.

sudo systemctl restart apache2

To reload Apache without dropping connections.

sudo systemctl reload apache2

To disable Apache.

sudo systemctl disable apache2

To enable Apache.

sudo systemctl enable apache2

Prepare yourself for a role working as an Information Technology Professional with Linux operating system


Now you have learned how to install Apache2 on Ubuntu 20.04.

Thanks for your time. If you face any problem or any feedback, please leave a comment below.

Write A Comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.