How To Install apache2 on Ubuntu 20.04

In this tutorial we learn how to install apache2 on Ubuntu 20.04. apache2 is Apache HTTP Server Apache HTTP Server Apache HTTP Server

Introduction

In this tutorial we learn how to install apache2 on Ubuntu 20.04.

What is apache2

apache2 is:

The Apache HTTP Server Project’s goal is to build a secure, efficient and extensible HTTP server as standards-compliant open source software. The result has long been the number one web server on the Internet.

Installing this package results in a full installation, including the configuration files, init scripts and support scripts. Task: lamp-server

Package: apache2 Architecture: amd64 Version: 2.4.41-4ubuntu3.3 Priority: optional Section: web Origin: Ubuntu Maintainer: Ubuntu Developers [email protected] Original-Maintainer: Debian Apache Maintainers [email protected] Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 529 Provides: httpd, httpd-cgi Pre-Depends: dpkg (>= 1.17.14) Depends: apache2-bin (= 2.4.41-4ubuntu3.3), apache2-data (= 2.4.41-4ubuntu3.3), apache2-utils (= 2.4.41-4ubuntu3.3), lsb-base, mime-support, perl:any, procps Recommends: ssl-cert Suggests: apache2-doc, apache2-suexec-pristine | apache2-suexec-custom, www-browser, ufw Conflicts: apache2.2-bin, apache2.2-common Breaks: libapache2-mod-proxy-uwsgi (« 2.4.33) Replaces: apache2.2-bin, apache2.2-common, libapache2-mod-proxy-uwsgi (« 2.4.33) Filename: pool/main/a/apache2/apache2_2.4.41-4ubuntu3.3_amd64.deb Size: 95500 MD5sum: ca84c49b21fa1ab4fadd35e0af3651cd SHA1: 3fa9e5950ee9f2d8baf961127579cc10a039eaa9 SHA256: 979817175a17785d1a0c0ae5c0b5f18a449bdfdfcfb5d0cd37a6b838f6c3236b SHA512: 674b3073e9c766f8d8bf1f804fa2642bddeb0887b6fd2e16d5fb26721f7153d27ca36ffccbce8a094b6bb64eee482c4bccd7f1f8aeb450ea5c9ddffa70d5c490 Homepage: https://httpd.apache.org/ Description-en: Apache HTTP Server The Apache HTTP Server Project’s goal is to build a secure, efficient and extensible HTTP server as standards-compliant open source software. The result has long been the number one web server on the Internet.

Installing this package results in a full installation, including the configuration files, init scripts and support scripts. Task: lamp-server

Package: apache2 Architecture: amd64 Version: 2.4.41-4ubuntu3 Priority: optional Section: web Origin: Ubuntu Maintainer: Ubuntu Developers [email protected] Original-Maintainer: Debian Apache Maintainers [email protected] Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 528 Provides: httpd, httpd-cgi Pre-Depends: dpkg (>= 1.17.14) Depends: apache2-bin (= 2.4.41-4ubuntu3), apache2-data (= 2.4.41-4ubuntu3), apache2-utils (= 2.4.41-4ubuntu3), lsb-base, mime-support, perl:any, procps Recommends: ssl-cert Suggests: apache2-doc, apache2-suexec-pristine | apache2-suexec-custom, www-browser, ufw Conflicts: apache2.2-bin, apache2.2-common Breaks: libapache2-mod-proxy-uwsgi (« 2.4.33) Replaces: apache2.2-bin, apache2.2-common, libapache2-mod-proxy-uwsgi (« 2.4.33) Filename: pool/main/a/apache2/apache2_2.4.41-4ubuntu3_amd64.deb Size: 95504 MD5sum: 2d88324bc5128985e8d56e8f4fa31f27 SHA1: 9148fd37cf821d98c29355a3c5a7ec0bd3c33336 SHA256: b9755bfe66825b53db1371cb163c14ceb7d436a6b5d2bfe09d6ccb8a98746b95 Homepage: https://httpd.apache.org/ Description-en: Apache HTTP Server The Apache HTTP Server Project’s goal is to build a secure, efficient and extensible HTTP server as standards-compliant open source software. The result has long been the number one web server on the Internet.

Installing this package results in a full installation, including the configuration files, init scripts and support scripts. Task: lamp-server

There are three methods to install apache2 on Ubuntu 20.04. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install apache2 Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install apache2 using apt-get by running the following command:

sudo apt-get -y install apache2

Install apache2 Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install apache2 using apt by running the following command:

sudo apt -y install apache2

Install apache2 Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install apache2 using aptitude by running the following command:

sudo aptitude -y install apache2

How To Uninstall apache2 on Ubuntu 20.04

To uninstall only the apache2 package we can use the following command:

sudo apt-get remove apache2

Uninstall apache2 And Its Dependencies

To uninstall apache2 and its dependencies that are no longer needed by Ubuntu 20.04, we can use the command below:

sudo apt-get -y autoremove apache2

Remove apache2 Configurations and Data

To remove apache2 configuration and data from Ubuntu 20.04 we can use the following command:

sudo apt-get -y purge apache2

Remove apache2 configuration, data, and all of its dependencies

We can use the following command to remove apache2 configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge apache2

References

Summary

In this tutorial we learn how to install apache2 package on Ubuntu 20.04 using different package management tools: apt, apt-get and aptitude.