Install Apache 2.4 on Ubuntu 20.04

Apache HTTP Server is a cross-platform web server which serves web content to a clients who request it. Apache is an open-source project which released under the Apache License 2.0.

This tutorial explains how to install Apache 2.4 on Ubuntu 20.04.

Install Apache

Add the Apache repository:

sudo add-apt-repository -y ppa:ondrej/apache2

Run the following command to install Apache:

sudo apt install -y apache2

When it finished, we can check version of Apache:

apache2 -v

You can use the following command to determine if Apache service is running:

sudo service apache2 status

Also you can stop, start and restart the Apache service:

sudo service apache2 stop
sudo service apache2 start
sudo service apache2 restart

Testing Apache

Get the IP address of your machine:

hostname -I

Open a browser and enter IP address. You will see default page of Apache which looks like:

Apache default page on Ubuntu

Uninstall Apache

If you wish to completely remove Apache and related dependencies, run the following command:

sudo apt purge --autoremove -y apache2

Remove GPG key and repository:

sudo rm -rf /etc/apt/trusted.gpg.d/ondrej_ubuntu_apache2.gpg
sudo rm -rf /etc/apt/sources.list.d/ondrej-ubuntu-apache2-focal.list

You can also remove Apache configuration and data:

sudo rm -rf /etc/apache2
sudo rm -rf /var/lib/apache2

Leave a Comment

Your email address will not be published.