How to Check & Install Specific Apache version on Ubuntu Linux

This post shows students and new users steps to find out what version of Apache is running on their server or install a specific Apache version on Ubuntu Linux. For users who want to know what version of Apache is running on their server, the steps below will show them how.

For those who also want to know how to install a specific version on Apache on Ubuntu Linux, the steps below will also show them how to do that. The steps will also include options to find out what modules are loaded with Apache on Ubuntu Linux as well.

For those who don’t know Apache is, here’s an overview:

Apache is the most popular open source web server in the world. Chances are many of the websites you visit today mostly likely are running Apache HTTP server. And if you’re thinking of running a website, you find yourself using Apache web server as well.

To get started with find out what version of Apache you’re running, or installing a specific Apache version on Ubuntu Linux, continue below.

How to find out what version of Apache you are running in Ubuntu Linux

Installing Apache on Ubuntu Linux is easy. Simply run the apt-get install apache2 commands to get it installed.

On Ubuntu Linux command console, run the commands below to check Apache version.

apache2 -v
# OR
apachectl -v

Once you run the command above, it should output similar lines as below:

Server version: Apache/2.4.41 (Ubuntu)
Server built:   2021-10-14T16:24:43

As you can see, the version number 2.4.41 is the latest version currently available in Ubuntu repository, however, it doesn’t mean that it is the latest version of Apache available to be installed.

You may also be able to find more info by running the commands below:

apt info apache2

When you run the commands above, it should list similar lines as below:

Package: apache2
Version: 2.4.41-4ubuntu3.8
Priority: optional
Section: web
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Debian Apache Maintainers <debian-apache@lists.debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug

If you have curl installed, you may also be able to tell what version of Apache running on Ubuntu Linux by using the commands below:

curl -I http://localhost/

When run the commands above, it should list something similar to the lines below:

HTTP/1.1 200 OK
Date: Mon, 27 Dec 2021 18:06:03 GMT
Server: Apache/2.4.41 (Ubuntu)
Last-Modified: Mon, 27 Dec 2021 17:52:16 GMT
ETag: "2aa6-5d4245d84cdaf"
Accept-Ranges: bytes
Content-Length: 10918
Vary: Accept-Encoding
Content-Type: text/html

How to find out what Apache modules are currently loaded in Ubuntu Linux

Now that you know how to find out what version of Apache installed on your system, the commands below show you how to list all the modules that are currently loaded with Apache.

apache2ctl -M

Once you run the commands above, it should output similar lines as below.

Loaded Modules:
 core_module (static)
 so_module (static)
 watchdog_module (static)
 http_module (static)
 log_config_module (static)
 logio_module (static)
 version_module (static)
 unixd_module (static)
 access_compat_module (shared)
 alias_module (shared)
 auth_basic_module (shared)
 authn_core_module (shared)
 authn_file_module (shared)
 authz_core_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 filter_module (shared)
 mime_module (shared)
 mpm_event_module (shared)
 negotiation_module (shared)
 reqtimeout_module (shared)
 setenvif_module (shared)
 status_module (shared)

Depending on your environment, the list above may be longer or shorted.

How to install specific version of Apache on Ubuntu Linux

By default, Ubuntu repository contains the latest stable version of Apache. When you install Apache from Ubuntu repository, it will only install that specific version available at that time.

If you need to install a specific version not available in Ubuntu Linux, you may have to add a third party repository to your system.

Run the commands below to add a repository to Ubuntu Linux that will allow you to install specific versions.

First, install the necessary commands below:

sudo apt update
sudo apt install software-properties-common

Next, run the commands below to add the repository.

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

After that, you can search for and install specific version of Apache.

apt-cache showpkg apache2

Install a specific version by running the command format below:

sudo apt-get install apache2=<complete version name>

Replace <complete version number> with the version number available for Ubuntu.

Example:

sudo apt install apache2=2.4.52-1+ubuntu20.04.1+deb.sury.org+1

Now the new version should reflect as shown below:

Server version: Apache/2.4.52 (Ubuntu)
Server built:   2021-12-20T21:07:12

That should do it!

Conclusion:

This post showed you how to check and install specific Apache version on Ubuntu Linux. If you find any error above or have something to add, please use the comment form below.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.