Centos7 php升级与依赖包下载
检查当前安装的PHP包
[root@kk ~]# yum list installed | grep php Repository epel is listed more than once in the configuration mod_php71w.x86_64 7.1.33-1.w7 installed php71w-cli.x86_64 7.1.33-1.w7 installed php71w-common.x86_64 7.1.33-1.w7 installed php71w-devel.x86_64 7.1.33-1.w7 installed php71w-embedded.x86_64 7.1.33-1.w7 installed php71w-fpm.x86_64 7.1.33-1.w7 installed php71w-gd.x86_64 7.1.33-1.w7 installed php71w-mbstring.x86_64 7.1.33-1.w7 installed php71w-mcrypt.x86_64 7.1.33-1.w7 installed php71w-mysqlnd.x86_64 7.1.33-1.w7 installed php71w-opcache.x86_64 7.1.33-1.w7 installed php71w-pdo.x86_64 7.1.33-1.w7 installed php71w-pear.noarch 1:1.10.4-1.w7 installed php71w-pecl-igbinary.x86_64 2.0.5-1.w7 installed php71w-pecl-memcached.x86_64 3.0.4-1.w7 installed php71w-pecl-mongodb.x86_64 1.5.3-1.w7 installed php71w-pecl-redis.x86_64 3.1.6-1.w7 installed php71w-process.x86_64 7.1.33-1.w7 installed php71w-xml.x86_64 7.1.33-1.w7 installed
移除当前PHP安装包,要是移除就要重新下载,不移除就升级,版本相差太大建议移除重新下载(我反正没有移除)
[root@kk ~]# yum remove php*
查看当前yum源都提供了哪些可安装的PHP版本
[root@kk ~]# yum list php*
注意:默认的yum源无法升级PHP,需要添加第三方yum源,我们选择webtatic库
CentOs 5.x
- rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpm
CentOs 6.x
- rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
CentOs 7.X
- rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
- rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
看一下当前yum源能下载哪些php的包
[root@kk yum.repos.d]# yum list php*
- 会发现只php55w-php72w,没有我想要的php73w,所以要用别的源来下载
我们先择REMI 源
[root@kk yum.repos.d]# yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
使用remi 源 升级 PHP 7.3
- 更改[remi]区域的代码块为如下,相同则不用更改
[root@kk yum.repos.d]# vim remi.repo [remi] name=Remi's RPM repository for Enterprise Linux 7 - $basearch #baseurl=http://rpms.remirepo.net/enterprise/7/remi/$basearch/ #mirrorlist=https://rpms.remirepo.net/enterprise/7/remi/httpsmirror mirrorlist=http://cdn.remirepo.net/enterprise/7/remi/mirror enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi [root@kk yum.repos.d]# vim remi-php73.repo [remi-php73] name=Remi's PHP 7.3 RPM repository for Enterprise Linux 7 - $basearch #baseurl=http://rpms.remirepo.net/enterprise/7/php73/$basearch/ mirrorlist=https://rpms.remirepo.net/enterprise/7/php73/httpsmirror mirrorlist=http://cdn.remirepo.net/enterprise/7/php73/mirror enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
然后进行升级
[root@kk yum.repos.d]# yum -y upgrade php*
- 查看版本
[root@kk yum.repos.d]# php -v PHP 7.3.13 (cli) (built: Dec 17 2019 10:29:15) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.13, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.13, Copyright (c) 1999-2018, by Zend Technologies [root@kk yum.repos.d]# rpm -qa|grep php php-opcache-7.3.13-1.el7.remi.x86_64 php-json-7.3.13-1.el7.remi.x86_64 php-cli-7.3.13-1.el7.remi.x86_64 php-pdo-7.3.13-1.el7.remi.x86_64 php-pecl-redis5-5.1.1-1.el7.remi.7.3.x86_64 php-mysqlnd-7.3.13-1.el7.remi.x86_64 php-embedded-7.3.13-1.el7.remi.x86_64 php-pecl-mcrypt-1.0.3-1.el7.remi.7.3.x86_64 php-common-7.3.13-1.el7.remi.x86_64 php-pecl-msgpack-2.0.3-1.el7.remi.7.3.x86_64 php-fedora-autoloader-1.0.0-1.el7.noarch php-process-7.3.13-1.el7.remi.x86_64 php-devel-7.3.13-1.el7.remi.x86_64 php-gd-7.3.13-1.el7.remi.x86_64 php-pear-1.10.10-4.el7.remi.noarch php-7.3.13-1.el7.remi.x86_64 php-fpm-7.3.13-1.el7.remi.x86_64 php-pecl-igbinary-3.1.0-1.el7.remi.7.3.x86_64 php-xml-7.3.13-1.el7.remi.x86_64 php-mbstring-7.3.13-1.el7.remi.x86_64 php-pecl-memcached-3.1.5-1.el7.remi.7.3.x86_64 php-pecl-mongodb-1.6.1-1.el7.remi.7.3.x86_64
不要忘记了启动php-fpm
[root@kk yum.repos.d]# systemctl start php-fpm [root@kk yum.repos.d]# systemctl enable php-fpm [root@kk yum.repos.d]# netstat -lntup|grep php tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 4536/php-fpm: maste
升级成功(升其它版本方法一致)
这里再说一下安装php73w依赖包
yum install -y php73-php-fpm php73-php-cli php73-php-bcmath php73-php-gd php73-php-json php73-php-mbstring php73-php-mcrypt php73-php-mysqlnd php73-php-opcache php73-php-pdo php73-php-pecl-crypto php73-php-pecl-mcrypt php73-php-pecl-geoip php73-php-recode php73-php-snmp php73-php-soap php73-php-xml
这里安装后启动php-fpm有些不一样,名称叫php73-php-fpm,才能启动
如果想要把这些包只下载不安装
yum install -y --downloadonly --downloaddir=/tmp/kk php73-php-fpm php73-php-cli php73-php-bcmath php73-php-gd php73-php-json php73-php-mbstring php73-php-mcrypt php73-php-mysqlnd php73-php-opcache php73-php-pdo php73-php-pecl-crypto php73-php-pecl-mcrypt php73-php-pecl-geoip php73-php-recode php73-php-snmp php73-php-soap php73-php-xml
wordpress无法将上传的文件移动至wp-content/uploads/2020/01。
这说一下要是完全升级,原先的php默认配置文件会发生变化,要去/etc/opt/remi/php73/php-fpm.d/www.conf,下把用户和用户组改成我们设定好的www,然后再重启php-fpm就完成了
继续阅读

我的微信
这是我的微信扫一扫
评论