#自带的只有5.4版本
yum provides php
[root@localhost etc]# yum provides phpLoaded plugins: fastestmirror, langpacksLoading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com * webtatic: uk.repo.webtatic.commod_php71w-7.1.26-1.w7.x86_64 : PHP module for the Apache HTTP ServerRepo : webtaticMatched from:Provides : php = 7.1.26-1.w7mod_php71w-7.1.27-1.w7.x86_64 : PHP module for the Apache HTTP ServerRepo : webtaticMatched from:Provides : php = 7.1.27-1.w7mod_php71w-7.1.28-1.w7.x86_64 : PHP module for the Apache HTTP ServerRepo : webtaticMatched from:Provides : php = 7.1.28-1.w7mod_php71w-7.1.29-1.w7.x86_64 : PHP module for the Apache HTTP ServerRepo : webtaticMatched from:Provides : php = 7.1.29-1.w7mod_php71w-7.1.30-1.w7.x86_64 : PHP module for the Apache HTTP ServerRepo : webtaticMatched from:Provides : php = 7.1.30-1.w7mod_php71w-7.1.31-1.w7.x86_64 : PHP module for the Apache HTTP ServerRepo : webtaticMatched from:Provides : php = 7.1.31-1.w7mod_php71w-7.1.32-1.w7.x86_64 : PHP module for the Apache HTTP ServerRepo : webtaticMatched from:Provides : php = 7.1.32-1.w7mod_php71w-7.1.33-1.w7.x86_64 : PHP module for the Apache HTTP ServerRepo : webtaticMatched from:Provides : php = 7.1.33-1.w7mod_php72w-7.2.14-1.w7.x86_64 : PHP module for the Apache HTTP ServerRepo : webtaticMatched from:Provides : php = 7.2.14-1.w7mod_php72w-7.2.16-1.w7.x86_64 : PHP module for the Apache HTTP ServerRepo : webtaticMatched from:Provides : php = 7.2.16-1.w7mod_php72w-7.2.17-1.w7.x86_64 : PHP module for the Apache HTTP ServerRepo : webtaticMatched from:Provides : php = 7.2.17-1.w7mod_php72w-7.2.19-1.w7.x86_64 : PHP module for the Apache HTTP ServerRepo : webtaticMatched from:Provides : php = 7.2.19-1.w7mod_php72w-7.2.21-1.w7.x86_64 : PHP module for the Apache HTTP ServerRepo : webtaticMatched from:Provides : php = 7.2.21-1.w7mod_php72w-7.2.22-1.w7.x86_64 : PHP module for the Apache HTTP ServerRepo : webtaticMatched from:Provides : php = 7.2.22-1.w7mod_php72w-7.2.24-1.w7.x86_64 : PHP module for the Apache HTTP ServerRepo : webtaticMatched from:Provides : php = 7.2.24-1.w7php-5.4.16-46.el7.x86_64 : PHP scripting language for creating dynamic web : sitesRepo : basephp-5.4.16-46.1.el7_7.x86_64 : PHP scripting language for creating dynamic : web sitesRepo : updatesphp55w-5.5.38-1.w7.x86_64 : PHP scripting language for creating dynamic web : sitesRepo : webtaticMatched from:Provides : php = 5.5.38-1.w7php56w-5.6.40-1.w7.x86_64 : PHP scripting language for creating dynamic web : sitesRepo : webtaticMatched from:Provides : php = 5.6.40-1.w7php70w-7.0.33-1.w7.x86_64 : PHP scripting language for creating dynamic web : sitesRepo : webtaticMatched from:Provides : php = 7.0.33-1.w7
#更新源
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
#移除系统自带的php-common
yum remove php-common -y
#安装依赖包
yum install -y php72w php72w-opcache php72w-xml php72w-mcrypt php72w-gd php72w-devel php72w-mysql php72w-intl php72w-mbstring
#版本变为7.2
php -v
显示以下结果
PHP 7.2.24 (cli) (built: Oct 26 2019 12:28:19) ( NTS )Copyright (c) 1997-2018 The PHP GroupZend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.24, Copyright (c) 1999-2018, by Zend Technologies