前言:
由于centos追求稳定,很多软件使用稳定的旧版,比如php,centos官方源默认为5.4,而php已经发展到了7.1版,很多应用对php的要求已经高于5.4
一、删除自带的php5.4
1、查看已有组件
[root@localhost lcr]# rpm -qa | grep php
php-cli-5.4.16-42.el7.x86_64
php-pear-1.9.4-21.el7.noarch
php-xml-5.4.16-42.el7.x86_64
php-common-5.4.16-42.el7.x86_64
php-process-5.4.16-42.el7.x86_64
php-gd-5.4.16-42.el7.x86_64
php-5.4.16-42.el7.x86_64
php-pdo-5.4.16-42.el7.x86_64
[root@centos-2 lcr]# yum remove php-common
二、添加官方源
CentOS/RHEL 7.x:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
三、安装php7.0
yum install -y php70w php70w-pecl-apcu php70w-xml php70w-mcrypt php70w-gd php70w-devel php70w-mysql php70w-intl php70w-mbstring
四、测试配置php
1、查看php版本
[root@localhost ~]# php -v
PHP 7.0.22 (cli) (built: Aug 9 2017 18:23:24) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
2、查看php详细信息
vi /var/www/html/info.php
输入一下内容
<?php
phpinfo()
?>
3、重启httpd
service httpd restart
or
systemctl httpd restart
4、访问测试
浏览器访问:local_IP/info.php
至此,安装完成