Control PanelUbuntuVesta CP

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

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

Sandeep B.

I'm a system admin and php developer and currently working as System Admin In CWP Control panel, expertise in Linux and Windows administration RHEL certified admin.

Related Articles

20 Comments

  1. 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.

      1. Hello, I tried your steps, but i had error in step 2.

        sudo add-apt-repository ppa:ondrej/apache2
        Cannot add PPA: ‘ppa:~ondrej/ubuntu/apache2’.
        ERROR: ‘~ondrej’ user or team does not exist.

        Could you help me, please?

  2. 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?

  3. 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?

  4. 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

  5. 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

Leave a Reply

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

Back to top button