php5.4升级php7
2020-04-21 09:44:57 来源:admin 点击:851
1:首先移除当前的php安装包,否则安装过程中会起冲突
yum remove php*
2:楼主使用的是rpm安装的,所以如果安装过程中报错(Couldn't resolve host 'mirrorlist.centos.org')(没有就直接跳过啦)
但是没有关系:只需要打开文件etc/下面的resolv.conf
在里面添加
nameserver 8.8.8.8
nameserver 8.8.4.4
search localdomain
接下来重启网卡就可以了:使用命令: service network restart
3:接下来就可以正式安装PHP7.2了
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm #更新源
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install -y php72w php72w-opcache php72w-xml php72w-mcrypt php72w-gd php72w-devel php72w-mysql php72w-intl php72w-mbstring #安装依赖包
结束后 输入 php -v 运行 就可以看到
好了 php7.2已经升级完成了
方法er
使用remi 源 升级 PHP 7.3
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpmrpm -Uvh https://rpms.remirepo.net/enterprise/remi-release-7.rpmcat <<EOF> /etc/yum.repos.d/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/httpsmirrormirrorlist=http://cdn.remirepo.net/enterprise/7/remi/mirrorenabled=0gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remiEOFcat <<EOF> /etc/yum.repos.d/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/httpsmirrormirrorlist=http://cdn.remirepo.net/enterprise/7/php73/mirrorenabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remiEOFyum -y upgrade php*
升级成功
# php -vPHP 7.3.5 (cli) (built: Apr 30 2019 08:37:17) ( NTS )Copyright (c) 1997-2018 The PHP GroupZend Engine v3.3.5, Copyright (c) 1998-2018 Zend Technologie
方法三
php -v
查看当前 PHP 相关的安装包,删除之
yum list installed | grep php yum remove php yum remove php-*
0|12.更换 RPM 源
#Centos 5.X: rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpm #CentOs 6.x: rpm -Uvh #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
0|13.安装新版本 PHP
php 7.0/7.1/7.2 分别表示为 70w/71w/72w目前(2018-5-4)CentOs 6.x 的 RPM 源中最高只有 7.1CentOs 7.x 的 RPM 源中有 7.2 yum install -y php71w php71w-cli php71w-common php71w-devel php71w-embedded php71w-fpm php71w-gd php71w-mbstring php71w-mysqlnd php71w-opcache php71w-pdo php71w-xml php71w-ldap php71w-mcrypt
0|14.再次检查版本
php -v