PHP 版本从 5.x 升级到 7.x

Posted 孟郎郎

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP 版本从 5.x 升级到 7.x相关的知识,希望对你有一定的参考价值。


如果把 Linux 服务器的 php 版本升级呢?比如目前版本是 PHP 5.6.40,升级到7.4 当前最最新版本 PHP 7.4.30。

查看当前 PHP 版本

 php -v

PHP

卸载已安装的 PHP

yum remove php-common

PHP

安装 EPEL 源

yum install epel-release

如果已安装过,则提示如下:

PHP

安装 remi 源

yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

PHP

安装 yum-config-manager

yum install yum-utils

PHP

指定 remi 的php 7.4 仓库

yum-config-manager --enable remi-php74

注意:如果要安装其它 PHP 版本,可以把上面命令中的 remi-php74 改为 remi-php72、remi-php71、remi-php70 等。

输出结果:

[root@langlang ~]# yum-config-manager --enable remi-php74
Loaded plugins: fastestmirror
============================================================ repo: remi-php74 ============================================================
[remi-php74]
async = True
bandwidth = 0
base_persistdir = /var/lib/yum/repos/x86_64/7
baseurl =
cache = 0
cachedir = /var/cache/yum/x86_64/7/remi-php74
check_config_file_age = True
compare_providers_priority = 80
cost = 1000
deltarpm_metadata_percentage = 100
deltarpm_percentage =
enabled = 1
enablegroups = True
exclude =
failovermethod = priority
ftp_disable_epsv = False
gpgcadir = /var/lib/yum/repos/x86_64/7/remi-php74/gpgcadir
gpgcakey =
gpgcheck = True
gpgdir = /var/lib/yum/repos/x86_64/7/remi-php74/gpgdir
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
hdrdir = /var/cache/yum/x86_64/7/remi-php74/headers
http_caching = all
includepkgs =
ip_resolve =
keepalive = True
keepcache = False
mddownloadpolicy = sqlite
mdpolicy = group:small
mediaid =
metadata_expire = 21600
metadata_expire_filter = read-only:present
metalink =
minrate = 0
mirrorlist = http://cdn.remirepo.net/enterprise/7/php74/mirror
mirrorlist_expire = 86400
name = Remis PHP 7.4 RPM repository for Enterprise Linux 7 - x86_64
old_base_cache_dir =
password =
persistdir = /var/lib/yum/repos/x86_64/7/remi-php74
pkgdir = /var/cache/yum/x86_64/7/remi-php74/packages
proxy = False
proxy_dict =
proxy_password =
proxy_username =
repo_gpgcheck = False
retries = 10
skip_if_unavailable = False
ssl_check_cert_permissions = True
sslcacert =
sslclientcert =
sslclientkey =
sslverify = True
throttle = 0
timeout = 30.0
ui_id = remi-php74
ui_repoid_vars = releasever,
basearch
username =

[root@langlang ~]#

安装升级 php

yum -y install php php-mysql gd php-gd gd-devel php-xml php-common php-mbstring php-ldap php-pear php-xmlrpc php-imap

验证升级后的 PHP 版本,结果如下:

PHP

Good Luck! 

以上是关于PHP 版本从 5.x 升级到 7.x的主要内容,如果未能解决你的问题,请参考以下文章

PHP版本升级5.3.25到5.6

Laravel Apache DirectoryIndex 现在需要 index.php

升级 SpringBoot 2.6.x 版本后,Swagger 没法用了

升级 SpringBoot 2.6.x 版本后,Swagger 没法用了

干货 | Elasticsearch 8.X 版本升级指南

干货 | Elasticsearch 8.X 版本升级指南