Update Apache 2.4 to Latest Version on Ubuntu 16.04/18.04 Server VestaCP

by Sandeep B.

In this tutorial we’ll be upgrading apache2 on Ubuntu 16.04 (also works with previous versions of Ubuntu) server to latest version, it is safe to upgrade & latest version of Apache includes many bug fixes and gain in performance also. It is recommended to update if you always like to have latest version for stability and feature updates.

Step 1 :

First we need to install this package :

apt-get install software-properties-common

Step 2 :

Adding this apache2 PPA by ondrej to your system

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

If you get this error (highlighted as red):

W: GPG error: http://ppa.launchpad.net/ondrej/apache2/ubuntu xenial InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4F4EA0AAE5267A6C
W: The repository 'http://ppa.launchpad.net/ondrej/apache2/ubuntu xenial InRelease' is not signed.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.

Then simply run this command and don’t forget to replace the NO_PUBKEY highlighted in red with your PUBKEY :

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 4F4EA0AAE5267A6C

Then again run :

apt-get update

You’ll see the error is gone now.

Step 3 :

Backup current apache config :

cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf.bak1

Then run this command finally to upgrade apache2 to latest version :

apt-get update
apt-get upgrade

Select NO when this Prompt screens appears :

Configuration file '/etc/apache2/apache2.conf'
 ==> Modified (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** apache2.conf (Y/I/N/O/D/Z) [default=N] ? N
Configuration file '/etc/logrotate.d/apache2'
 ==> Modified (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** apache2 (Y/I/N/O/D/Z) [default=N] ? N

DONE, you’ve now latest version of Apache 2.4 is installed on your server, to check the version of Apache run this command :

apache2 -v

If this post helps you in any way please consider a donation

Donate with PayPal :

md-donate

Donate with Paytm :

md-donate

You may also like

16 comments

Charles Warren III October 3, 2018 - 5:14 am

Very nice tutorial, any idea on a release date for Apache version 2.4.35 on this distro?

Reply
anony February 12, 2019 - 7:14 pm

i don’t think you want to run apt-get dist-upgrade, it will upgrade the entire OS from 16 to 18.

sudo add-apt-repository ppa:ondrej/apache2
sudo apt update
sudo apt install apache2
sudo service apache2 restart

Reply
foofel February 16, 2019 - 8:32 am

thanks bro

Reply
Zahid Ullah April 15, 2019 - 10:25 pm

nice very helpful

Reply
Preetpal Singh April 23, 2019 - 9:11 am

Just run sudo apt-get –only-upgrade install apache2
Don’t need to run dis-upgrade it will upgrade the os version and other packages

Reply
Marc Schröder May 25, 2019 - 2:27 am

Hi,

I have Debian 9.9 and Apache 2.4.25 It does not work for me! It is always shown to me that the latest version is installed.

Reply
Sandy May 24, 2019 - 8:58 pm

Hi this tutorial is for only Ubuntu

Reply
Ian October 2, 2019 - 9:46 am

This is a very useful article. Many thanks for taking the time to write it.

I have used it to upgrade Apache on some Linux servers.

But I have tried to upgrade from Apache 2.4.34 to the latest version of Apache 2.4.41 but I get a message saying that the server is already running the latest version of Apache.

Do you know how I can fix this?

Reply
Sandy October 2, 2019 - 12:20 pm

hello
please try the steps again and check if all commands are running successful.

Reply
Albert February 26, 2020 - 5:28 am

I have ubuntu 14.04.5 and apache version 2.4.29. I updated it using following commands and it updated.
sudo add-apt-repository ppa:ondrej/apache2
sudo apt update
sudo apt upgrade
when I tried to check the new version using /usr/sbin/apache2 -v it shows the old version that is 2.4.29

any suggestions?

Reply
Sandeep B. February 26, 2020 - 6:58 am

This tutorial is for ubuntu 16.04, you can try again by adding correct ppa for your version of ubuntu.

Reply
ALBERT February 26, 2020 - 7:16 am

How to do that? Should I have to update Ubuntu? How?

Reply
ALBERT February 26, 2020 - 7:15 am

How to do that? Should I have to update Ubuntu? How?

Reply
Sandeep B. February 26, 2020 - 7:16 am

Its better to.open a topic in our forum for better checkings.

Reply
Ashith April 26, 2020 - 12:17 pm

hi Sandeep, Followed your steps command by command but still getting the older version when doing apache -v.I am using Ubuntu 16.04.
Kindly suggest.

Reply
Sandeep B. April 26, 2020 - 2:53 pm

Hi did you followed all the steps correctly. I will invite you in our forum to discuss more about the issue.

Reply

Leave a Comment