1. 检查当前安装的 PHP 包
yum list installed | grep PHP
如果有安装的 PHP 包, 先删除他们
yum remove PHP.x86_64 PHP-cli.x86_64 PHP-common.x86_64 PHP-gd.x86_64 PHP-ldap.x86_64 PHP-mbstring.x86_64 PHP-mcrypt.x86_64 PHP-MySQL.x86_64 PHP-pdo.x86_64
配置 yum 源
CentOS 7.0 的源.
- yum install epel-release
- rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
使用 yum list 命令查看可安装的包 (Packege)
`yum list --enablerepo=remi --enablerepo=remi-php56 | grep php`
安装 PHP5.6.x
yum 源配置好了, 下一步就安装 PHP5.6.
yum install --enablerepo=remi --enablerepo=remi-php56 PHP PHP-opcache PHP-devel PHP-mbstring PHP-mcrypt PHP-mysqlnd PHP-phpunit-PHPUnit PHP-pecl-xdebug PHP-pecl-xhprof
用 PHP 命令查看版本.
- 1. PHP 5.6.38 (cli) (built: Oct 24 2018 12:50:38)
- 1. Copyright (c) 1997-2016 The PHP Group
- 1. Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
- 1. with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
- 1. with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans****
安装 PHP-fpm
yum install --enablerepo=remi --enablerepo=remi-php56 PHP-fpm
在这里安装的版本是 PHP5.6.13.
从 PHP5.5 开始 PHP 代码缓存从 APC 变成了 Zend OPcache 了.
重新启动服务:
- systemctl restart httpd
- systemctl restart PHP-fpm
来源: http://www.bubuko.com/infodetail-2865997.html