Install php7.2 CentOS 6.X and 7.X

As PHP versions 5.6 and 7.0 reach End Of Life you might want to update to something newer and supported, unfortunately the official CentOS repositories don’t have PHP versions 7.1 or 7.2 yet, but with a third-party repository and a bit of fiddling it’s easy to update, and more importantly keep it updated, your server PHP version.
 
Just run as root:


yum update -y
yum install epel-release wget -y
yum install yum-utils -y
CENTOS_VERSION=$(rpm --eval '%{centos_ver}')
wget http://rpms.famillecollet.com/enterprise/remi-release-${CENTOS_VERSION}.rpm
yum localinstall remi-release-${CENTOS_VERSION}.rpm -y
yum-config-manager --enable remi-php72
yum update -y
yum install php72 -y

 
Caveats:
1) This is a third-party repository you should carefully decide if you trust the owner of the repository or if you want to build it yourself, both options have merits and downsides.
 

Sources:

https://www.cyberciti.biz/faq/how-to-install-php-7-2-on-centos-7-rhel-7/
https://www.tecmint.com/install-php-7-in-centos-7/
https://www.rosehosting.com/blog/how-to-install-php-7-2-on-centos-7/