Installing the Latest Version of Apache

Ubuntu maintains a list of software for installation on your server, which can be searched and installed using the apt
package manager. Often though you will find that the version of software in the official Ubuntu repository is a
number of versions behind what is officially available from the software developer itself. This is due to the time and
work involved for the Ubuntu team to test, package and publish new software versions to make it available for
servers to use.

When a developer publishes a newer version of a product, the quickest way to install it on your server is to get it straight from that developer. To do this, you need to add the developers repository to the list of repositories your server knows about, so your server knows where to get this software from.

I recently wanted to upgrade the version of Apache on my server due to a newly announced security vulnerability
(CVE-2021-10438). I checked the currently installed version of Apache on my server by running:

apache2 –v

Seeing that it was behind the recommended version of 2.4.48, I checked if there was an update available for it:

sudo apt update
sudg apt upgrade apache2*

Checking the Apache version again, it was still at 2.4.41, so the version which was secure against this vulnerability must not yet be available in the official Ubuntu software repositories. To upgrade Apache to the newest version, I ran the following to add the apache repository:

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

and finally install the new version of Apache

sudo apt install apache2

Now you can check the new version;

apache2 -v

The restart Apache for the new version to take effect

sudo systemctl restart apache2