Steven SullivanSteven Sullivan - 16th March 2018

I’ve published one before on the VestaCP Forums regarding how to install PHP 7.0 on Centos 7 with VestaCP. This tutorial is now for PHP 7.2 which has increased performance over PHP 7.0 and 7.1. If you have a handful of WordPress websites on PHP 5, you should upgrade. If you’re on PHP 7.0 from my previous tutorials, or are using my Server Installer Script then this will also work for you. I would advise upgrading when you have time.

Note: This only works on NGINX + PHP-FPM VestaCP installs.

Install PHP 7.2 on CentOS 7

This method will completely remove any older PHP version.

If you have REMI Repository you can skip this step.

rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm

Then enable Remi

yum --enablerepo=remi update remi-release

Now remove old PHP and install PHP7

service php-fpm stop
yum -y --enablerepo=remi install php72-php php72-php-pear php72-php-bcmath php72-php-pecl-jsond-devel php72-php-mysqlnd php72-php-gd php72-php-common php72-php-fpm php72-php-intl php72-php-cli php72-php php72-php-xml php72-php-opcache php72-php-pecl-apcu php72-php-pecl-jsond php72-php-pdo php72-php-gmp php72-php-process php72-php-pecl-imagick php72-php-devel php72-php-mbstring

Remove and re-link new PHP 7.2

rm -f /usr/bin/php
ln -s /usr/bin/php72 /usr/bin/php

Test if we have PHP 7.2

php -v

Output should be (take note of PHP 7.2!!)

[[email protected] system]# php -v
PHP 7.2.3 (cli) (built: Mar  2 2018 12:24:56) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.3, Copyright (c) 1999-2018, by Zend Technologies

Now open up new PHP-FPM.conf ( [b]/etc/opt/remi/php72/php-fpm.conf[/b] ) file and change [b]line 11[/b] to:



service php72-php-fpm start

Remove old systemctl php-fpm and link to new one

rm -f /usr/lib/systemd/system/php-fpm.service
ln -s /usr/lib/systemd/system/php72-php-fpm.service /usr/lib/systemd/system/php-fpm.service

Reload systemctl daemon

systemctl daemon-reload

Now if you want to keep PHP 7.2 up-to-date when you do updates, you’ll need to disable the previous PHP 5 repos like so;

yum install yum-utils
yum-config-manager --disable remi-php56
yum-config-manager --disable remi-php55
yum-config-manager --disable remi-php56-debuginfo
yum-config-manager --disable remi-php55-debuginfo
yum clean all
yum update