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
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.
Hi did you followed all the steps correctly. I will invite you in our forum to discuss more about the issue.
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?
Please, could you help me?:(
hi the ppa is already there
https://launchpad.net/~ondrej/+archive/ubuntu/apache2
check the section “Adding this PPA to your system”
I mean for Ubuntu 16.04.01.
How to do that? Should I have to update Ubuntu? How?
Its better to.open a topic in our forum for better checkings.
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?
This tutorial is for ubuntu 16.04, you can try again by adding correct ppa for your version of ubuntu.
How to do that? Should I have to update Ubuntu? How?
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?
hello
please try the steps again and check if all commands are running successful.
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.
Hi this tutorial is for only Ubuntu
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
nice very helpful
thanks bro
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
Very nice tutorial, any idea on a release date for Apache version 2.4.35 on this distro?