Upgrade PHP from 7.0 to 7.2

A long ago, I wrote about how to upgrade to 7.0. PHP 7.2 is released. Now, it’s the time again to upgrade to the new version.

 The latest version of PHP comes with a couple of changes

More details: http://php.net/releases/7_2_0.php

Even it’s your first time, just follow the following steps. First, update your system.

sudo apt-get update
sudo apt-get install python-software-properties

Second, add Ondřej’s PPA to the system’s Apt sources:

sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php

Update your local package cache again

sudo apt-get update

Now Install PHP 7.2

sudo apt-get install php7.2

In order to version check, run: php -v

You also need to install some modules

sudo apt-get install libapache2-mod-php7.2 php7.2-cgi php7.2-cli php7.2-common php7.2-curl php7.2-gd php7.2-imap php7.2-intl php7.2-json php7.2-ldap php7.2-mbstring php7.2-mysql php7.2-opcache php7.2-pspell php7.2-readline php7.2-soap php7.2-xml php7.2-zip

One more module for Nginx server

sudo apt-get install php7.2-fpm



You can ignore the following steps if you install PHP 7.2 for first time.

For Nginx Server

Update the unix socket path at default configuration as well as other configurations. 


estart the Nginx server

sudo service nginx restart

For Apache server

You need to disable the old version on Apache and tell Apache to use PHP 7.2.

sudo a2dismod php7.0  
sudo a2enmod php7.2

Restart the Apache server

sudo /etc/init.d/apache2 restart

Now, you can remove the old version.


sudo apt-get install ppa-purge
sudo apt-get purge php7.0-common

Happy hacking 🙂



Eftakhairul Islam

Hi, I'm Eftakhairul Islam, a passionate Software Engineer, Hacker and Open Source Enthusiast. I enjoy writing about technical things, work in a couple of startup as a technical advisor and in my spare time, I contribute a lot of open source projects.


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.

Read previous post:
GIT Squashing and open source contribution

Never thought that GIT squashing would be that important for the open source contribution. I was contributing to an open source project....