Using phpinfo(), I have found that the installed version of PHP is 7.0.26. I want to upgrade it to PHP 7.2.


You have to install the PHP 7.2 (or any higher version 7.x) and remove your old version if you don't need it any more.

First add the PPA ppa:ondrej/php, run:

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

Second install the version you need 7.2 in your case, run:

sudo apt install php7.2

Third if you want to remove your old existing version, run

sudo apt remove php7.0
  • Probably the php module for apache2 should be installed and enabled: sudo apt install libapache2-mod-php7.x && a2enmod php7.x, where x refers to the certain version.. – pa4080 Dec 28 '17 at 11:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.