PHP 版本从 5.x 升级到 7.x
如果把 Linux 服务器的 PHP 版本升级呢?比如目前版本是 PHP 5.6.40,升级到7.4 当前最最新版本 PHP 7.4.30。
查看当前 PHP 版本
php -v
卸载已安装的 PHP
yum remove php-common
安装 EPEL 源
yum install epel-release
如果已安装过,则提示如下:
安装 remi 源
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
安装 yum-config-manager
yum install yum-utils
指定 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 = Remi's 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 版本,结果如下:
Good Luck!