阿里云将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

  

#升级php为5.6的另一种方式
#查看删除php yum list installed | grep php yum remove php-common #升级安装php5.6 yum install epel-release rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm 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-fpm php-redis php-gd #设置php时区和php-fpm用户组 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

  

posted on 2017-10-13 18:31  loveking_阳  阅读(262)  评论(0编辑  收藏  举报

导航