How To Update PHP 7.0 to PHP 7.2 on Debian Easily

Share This Post

Share on facebook
Share on linkedin
Share on twitter
Share on email

Last Updated: June 27, 2020 | Reading Time: < 1 minute

More than a year a go, I wrote about how to upgrade PHP 5.6 to PHP 7.0.

Now, PHP 7.0 will reached the end of its critical support through December 2018. After that date PHP community will no longer provides support for bugs. Following to PHP 7.0, PHP 7.1 will be put under discontinued support next year.

Also, since dotdeb dropped support for PHP 7.1 and later so we will use another package provided by Ondřej Surý’s.

Let’s get into the action.

Installing Ondřej’s Package

sudo apt install apt-transport-https lsb-release ca-certificates
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg
sudo sh -c 'echo "deb $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
sudo apt-get update

then, install php 7.2

sudo apt-get install php7.2-fpm

installing php7.2-fpm will automatically install another dependencies, so don’t bother by installing them one by one.

Install php-mysql

sudo apt-get install php7.2-mysql

Configuring Nginx Server Block

You can change the block in every domain configuration if you want to use multiple php install. To change a domain to use PHP 7.2 open the server block:

sudo vi /etc/nginx/site-available/


fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;


fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;

Start PHP 7.2 and Shutdown PHP 7.0

sudo etc/init.d/php7.2-fpm start

If you want to shutdown the PHP 7.0

sudo etc/init.d/php7.0-fpm stop

Restart Nginx

sudo /etc/init.d/nginx restart

Now your sites running under PHP 7.2.

Remove Old PHP 7.0 Packages (optional)

If you are ready to move on, let’s proceed on the removal:

x="$(dpkg --list | grep php7.0 | awk '/^ii/{ print $2}')" [press enter]
sudo apt-get --purge remove $x


Any idea? Fill the comment below

This site uses Akismet to reduce spam. Learn how your comment data is processed.

More To Explore