web analytics

Install PHP7.2 on Centos7

PHP 7.2 does not come by default with Centos base repo. Hence, in order to install it we first need to install and enable the remi repo and then install PHP. Execute the following commands in the below order to get PHP 7.2 installed on Centos7.

 

[root@de56f5fc317d ~]# yum update

[root@de56f5fc317d ~]# yum install yum-utils

[root@de56f5fc317d ~]# yum install epel-release

[root@de56f5fc317d ~]# yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

[root@de56f5fc317d ~]# yum-config-manager –enable remi-php72

 

Now, check if PHP 7.2 packages are available.

[root@de56f5fc317d yum.repos.d]# yum list available php72
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
* base: centos.mirrors.nublue.co.uk
* epel: lon.mirror.rackspace.com
* extras: mirror.vorboss.net
* remi-php72: mirror.serverion.com
* remi-safe: mirror.serverion.com
* updates: mirror.sov.uk.goscomb.net
remi-php72 | 3.0 kB 00:00:00
remi-safe | 3.0 kB 00:00:00
(1/2): remi-php72/primary_db | 228 kB 00:00:00
(2/2): remi-safe/primary_db | 1.6 MB 00:00:01
Available Packages
php72.x86_64 2.0-1.el7.remi remi-safe

 

Now, you can proceed with PHP 7.2 installation and any required php modules as follows.

[root@de56f5fc317d ~]# yum install -y php72 php72-php-pdo php72-php-mysqlnd php72-php-opcache php72-php-xml php72-php-gd php72-php-devel php72-php-mysql php72-php-intl php72-php-mbstring php72-php-bcmath php72-php-json php72-php-iconv php72-php-fpm php72-php-soap php72-php-mcrypt

Make sure your required packages are getting installed and type ‘y’ when prompted for confirmation to continue.

Screenshot from 2019-10-19 11-46-03

Once installation is successful, check the version of PHP running.

[root@de56f5fc317d ~]# php72 -v
PHP 7.2.23 (cli) (built: Sep 25 2019 07:56:34) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.23, Copyright (c) 1999-2018, by Zend Technologies

 

Now add a PHPinfo file with the following code and try executing it in browser to make sure PHP files will be served correctly.

<?php

phpinfo();

?>

Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>