将centos 7 自带的 php 5.4升级为 5.6

Posted JonlysLee

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了将centos 7 自带的 php 5.4升级为 5.6相关的知识,希望对你有一定的参考价值。

1、php -v 
PHP 5.4.16 (cli) (built: Nov 6 2016 00:29:02) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

  

2、执行下面的命令升级软件仓库 
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm 
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

  

3、执行下面的命令删除php 
yum remove php-common 
然后像安装那样问你是否继续的,输入yes即可

yum list installed | grep php 
yum remove php56w.x86_64 
yum remove ....

  

4、安装php 5.6版本
yum install -y php56w php56w-opcache php56w-xml php56w-mcrypt php56w-gd php56w-devel php56w-mysql php56w-intl php56w-mbstring

  

5、安装PHP FPM
yum install php56w-fpm
systemctl enable php-fpm.service【开机自启动】
/bin/systemctl start php-fpm.service 【启动php-fpm】

  

6、查看版本
PHP 5.6.31 (cli) (built: Sep 14 2017 18:12:46) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

 

sed -i ‘s/^;date\.timezone\ =/date\.timezone\ =\ "Asia\/Shanghai"/‘ /etc/php.ini

sed -i ‘s/^user\ =\ apache/user\ =\ nginx/‘ /etc/php-fpm.d/www.conf
sed -i ‘s/^group\ =\ apache/group\ =\ nginx/‘ /etc/php-fpm.d/www.conf

 

/bin/systemctl restart php-fpm.service
/bin/systemctl restart nginx.service

  

以上是关于将centos 7 自带的 php 5.4升级为 5.6的主要内容,如果未能解决你的问题,请参考以下文章

centos7 升级php版本到7.2

两行代码搞定CentOS环境升级PHP

centos7升级php5.4到php5.6

centos6.7自带python升级为python2.7

将centos6的php5.3升级为5.6

CentOS 7 安装PHP7+Nginx+Mysql5.7开发环境