虚拟机上的一台centos7,本来只打算升级一下php5到php7的,想来一直没试过update,索性练习学习一下。
首先最重要的当然是备份了,因为是虚拟机,备份非常方便,整个快照一下即可。
查看一下现在的版本
# mysql -V
mysql Ver 15.1 Distrib 5.5.64-MariaDB, for Linux (x86_64) using readline 5.1
# php -v
PHP 5.4.16 (cli) (built: Aug 11 2016 21:24:59)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
# httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built: Jul 18 2016 15:30:14
# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
然后运行升级
# yum clean all
# yum update
中途输入y回车确认一下升级
已安装:
NetworkManager.x86_64 1:1.18.0-5.el7_7.2
NetworkManager-ppp.x86_64 1:1.18.0-5.el7_7.2
grub2.x86_64 1:2.02-0.80.el7.centos
grub2-tools.x86_64 1:2.02-0.80.el7.centos
grub2-tools-extra.x86_64 1:2.02-0.80.el7.centos
grub2-tools-minimal.x86_64 1:2.02-0.80.el7.centos
kernel.x86_64 0:3.10.0-1062.18.1.el7
python-gobject-base.x86_64 0:3.22.0-1.el7_4.1
rdma-core.i686 0:22.1-3.el7
rdma-core.x86_64 0:22.1-3.el7
作为依赖被安装:
GeoIP.x86_64 0:1.5.0-14.el7
audit-libs.i686 0:2.8.5-4.el7
bind-export-libs.x86_64 32:9.11.4-9.P2.el7
bzip2-libs.i686 0:1.0.6-13.el7
cracklib.i686 0:2.9.0-11.el7
elfutils-default-yama-scope.noarch 0:0.176-2.el7
elfutils-libelf.i686 0:0.176-2.el7
elfutils-libs.i686 0:0.176-2.el7
firewalld-filesystem.noarch 0:0.6.3-2.el7_7.4
geoipupdate.x86_64 0:2.5.0-1.el7
glibc.i686 0:2.17-292.el7
grub2-common.noarch 1:2.02-0.80.el7.centos
grub2-pc.x86_64 1:2.02-0.80.el7.centos
grub2-pc-modules.noarch 1:2.02-0.80.el7.centos
ipset.x86_64 0:7.1-1.el7
ipset-libs.x86_64 0:7.1-1.el7
libattr.i686 0:2.4.46-13.el7
libcap.i686 0:2.22-10.el7
libcap-ng.i686 0:0.7.5-4.el7
libdb.i686 0:5.3.21-25.el7
libfastjson.x86_64 0:0.99.4-3.el7
libgcc.i686 0:4.8.5-39.el7
libgcrypt.i686 0:1.5.3-14.el7
libgpg-error.i686 0:1.12-3.el7
libselinux.i686 0:2.5-14.1.el7
libsepol.i686 0:2.5-10.el7
libsmartcols.x86_64 0:2.23.2-61.el7_7.1
libstdc++.i686 0:4.8.5-39.el7
lz4.i686 0:1.7.5-3.el7
lz4.x86_64 0:1.7.5-3.el7
nss-pem.x86_64 0:1.0.3-7.el7
nss-softokn-freebl.i686 0:3.44.0-8.el7_7
pam.i686 0:1.1.8-22.el7
pciutils.x86_64 0:3.5.1-3.el7
pcre.i686 0:8.32-17.el7
python-firewall.noarch 0:0.6.3-2.el7_7.4
python-linux-procfs.noarch 0:0.4.11-4.el7
python-schedutils.x86_64 0:0.4-6.el7
systemd-libs.i686 0:219-67.el7_7.4
xz-libs.i686 0:5.2.2-1.el7
zlib.i686 0:1.2.7-18.el7
更新完毕:
NetworkManager-libnm.x86_64 1:1.18.0-5.el7_7.2
NetworkManager-team.x86_64 1:1.18.0-5.el7_7.2
NetworkManager-tui.x86_64 1:1.18.0-5.el7_7.2
acl.x86_64 0:2.2.51-14.el7
alsa-lib.x86_64 0:1.1.8-1.el7
alsa-tools-firmware.x86_64 0:1.1.0-1.el7
apr.x86_64 0:1.4.8-5.el7
audit.x86_64 0:2.8.5-4.el7
audit-libs.x86_64 0:2.8.5-4.el7
authconfig.x86_64 0:6.2.8-30.el7
avahi-autoipd.x86_64 0:0.6.31-19.el7
avahi-libs.x86_64 0:0.6.31-19.el7
bash.x86_64 0:4.2.46-33.el7
bind-libs-lite.x86_64 32:9.11.4-9.P2.el7
bind-license.noarch 32:9.11.4-9.P2.el7
binutils.x86_64 0:2.27-41.base.el7_7.3
biosdevname.x86_64 0:0.7.3-2.el7
btrfs-progs.x86_64 0:4.9.1-1.el7
ca-certificates.noarch 0:2019.2.32-76.el7_7
centos-release.x86_64 0:7-7.1908.0.el7.centos
chkconfig.x86_64 0:1.7.4-1.el7
coreutils.x86_64 0:8.22-24.el7
cpio.x86_64 0:2.11-27.el7
cpp.x86_64 0:4.8.5-39.el7
cronie.x86_64 0:1.4.11-23.el7
cronie-anacron.x86_64 0:1.4.11-23.el7
cryptsetup-libs.x86_64 0:2.0.3-5.el7
curl.x86_64 0:7.29.0-54.el7_7.2
cyrus-sasl-lib.x86_64 0:2.1.26-23.el7
dbus.x86_64 1:1.10.24-13.el7_6
dbus-libs.x86_64 1:1.10.24-13.el7_6
device-mapper.x86_64 7:1.02.158-2.el7_7.2
device-mapper-event.x86_64 7:1.02.158-2.el7_7.2
device-mapper-event-libs.x86_64 7:1.02.158-2.el7_7.2
device-mapper-libs.x86_64 7:1.02.158-2.el7_7.2
device-mapper-persistent-data.x86_64 0:0.8.5-1.el7
dhclient.x86_64 12:4.2.5-77.el7.centos
dhcp-common.x86_64 12:4.2.5-77.el7.centos
dhcp-libs.x86_64 12:4.2.5-77.el7.centos
diffutils.x86_64 0:3.3-5.el7
dmidecode.x86_64 1:3.2-3.el7
dnsmasq.x86_64 0:2.76-10.el7_7.1
dracut.x86_64 0:033-564.el7
dracut-config-rescue.x86_64 0:033-564.el7
dracut-network.x86_64 0:033-564.el7
e2fsprogs.x86_64 0:1.42.9-16.el7
e2fsprogs-libs.x86_64 0:1.42.9-16.el7
ebtables.x86_64 0:2.0.10-16.el7
elfutils-libelf.x86_64 0:0.176-2.el7
elfutils-libs.x86_64 0:0.176-2.el7
ethtool.x86_64 2:4.8-10.el7
expat.x86_64 0:2.1.0-10.el7_3
file.x86_64 0:5.11-35.el7
file-libs.x86_64 0:5.11-35.el7
filesystem.x86_64 0:3.2-25.el7
findutils.x86_64 1:4.5.11-6.el7
fipscheck.x86_64 0:1.4.1-6.el7
fipscheck-lib.x86_64 0:1.4.1-6.el7
firewalld.noarch 0:0.6.3-2.el7_7.4
freetype.x86_64 0:2.8-14.el7
gawk.x86_64 0:4.0.2-4.el7_3.1
gcc.x86_64 0:4.8.5-39.el7
gcc-c++.x86_64 0:4.8.5-39.el7
gettext.x86_64 0:0.19.8.1-2.el7
gettext-libs.x86_64 0:0.19.8.1-2.el7
git.x86_64 0:1.8.3.1-21.el7_7
glib-networking.x86_64 0:2.56.1-1.el7
glib2.x86_64 0:2.56.1-5.el7
glibc.x86_64 0:2.17-292.el7
glibc-common.x86_64 0:2.17-292.el7
glibc-devel.x86_64 0:2.17-292.el7
glibc-headers.x86_64 0:2.17-292.el7
gmp.x86_64 1:6.0.0-15.el7
gnupg2.x86_64 0:2.0.22-5.el7_5
gnutls.x86_64 0:3.3.29-9.el7_6
gobject-introspection.x86_64 0:1.56.1-1.el7
gpm-libs.x86_64 0:1.20.7-6.el7
grep.x86_64 0:2.20-3.el7
grubby.x86_64 0:8.28-26.el7
gsettings-desktop-schemas.x86_64 0:3.28.0-2.el7
gzip.x86_64 0:1.5-10.el7
hostname.x86_64 0:3.13-3.el7_7.1
httpd.x86_64 0:2.4.6-90.el7.centos
httpd-tools.x86_64 0:2.4.6-90.el7.centos
hwdata.x86_64 0:0.252-9.3.el7
info.x86_64 0:5.1-5.el7
initscripts.x86_64 0:9.49.47-1.el7
iproute.x86_64 0:4.11.0-25.el7_7.2
iprutils.x86_64 0:2.4.17.1-3.el7_7
iptables.x86_64 0:1.4.21-33.el7
iputils.x86_64 0:20160308-10.el7
irqbalance.x86_64 3:1.0.7-12.el7
iwl100-firmware.noarch 0:39.31.5.1-72.el7
iwl1000-firmware.noarch 1:39.31.5.1-72.el7
iwl105-firmware.noarch 0:18.168.6.1-72.el7
iwl135-firmware.noarch 0:18.168.6.1-72.el7
iwl2000-firmware.noarch 0:18.168.6.1-72.el7
iwl2030-firmware.noarch 0:18.168.6.1-72.el7
iwl3160-firmware.noarch 0:22.0.7.0-72.el7
iwl3945-firmware.noarch 0:15.32.2.9-72.el7
iwl4965-firmware.noarch 0:228.61.2.24-72.el7
iwl5000-firmware.noarch 0:8.83.5.1_1-72.el7
iwl5150-firmware.noarch 0:8.24.2.2-72.el7
iwl6000-firmware.noarch 0:9.221.4.1-72.el7
iwl6000g2a-firmware.noarch 0:17.168.5.3-72.el7
iwl6000g2b-firmware.noarch 0:17.168.5.2-72.el7
iwl6050-firmware.noarch 0:41.28.5.1-72.el7
iwl7260-firmware.noarch 0:22.0.7.0-72.el7
iwl7265-firmware.noarch 0:22.0.7.0-72.el7
jansson.x86_64 0:2.10-1.el7
kbd.x86_64 0:1.15.5-15.el7
kbd-legacy.noarch 0:1.15.5-15.el7
kbd-misc.noarch 0:1.15.5-15.el7
kernel-headers.x86_64 0:3.10.0-1062.18.1.el7
kernel-tools.x86_64 0:3.10.0-1062.18.1.el7
kernel-tools-libs.x86_64 0:3.10.0-1062.18.1.el7
kexec-tools.x86_64 0:2.0.15-33.el7
kmod.x86_64 0:20-25.el7_7.1
kmod-libs.x86_64 0:20-25.el7_7.1
kpartx.x86_64 0:0.4.9-127.el7
krb5-libs.x86_64 0:1.15.1-37.el7_7.2
libX11.x86_64 0:1.6.7-2.el7
libX11-common.noarch 0:1.6.7-2.el7
libXpm.x86_64 0:3.5.12-1.el7
libacl.x86_64 0:2.2.51-14.el7
libattr.x86_64 0:2.4.46-13.el7
libblkid.x86_64 0:2.23.2-61.el7_7.1
libcap.x86_64 0:2.22-10.el7
libcom_err.x86_64 0:1.42.9-16.el7
libcroco.x86_64 0:0.6.12-4.el7
libcurl.x86_64 0:7.29.0-54.el7_7.2
libdb.x86_64 0:5.3.21-25.el7
libdb-utils.x86_64 0:5.3.21-25.el7
libdrm.x86_64 0:2.4.97-2.el7
libffi.x86_64 0:3.0.13-18.el7
libgcc.x86_64 0:4.8.5-39.el7
libgcrypt.x86_64 0:1.5.3-14.el7
libgomp.x86_64 0:4.8.5-39.el7
libgudev1.x86_64 0:219-67.el7_7.4
libjpeg-turbo.x86_64 0:1.2.90-8.el7
libmount.x86_64 0:2.23.2-61.el7_7.1
libndp.x86_64 0:1.2-9.el7
libnetfilter_conntrack.x86_64 0:1.0.6-1.el7_3
libnl3.x86_64 0:3.2.28-4.el7
libnl3-cli.x86_64 0:3.2.28-4.el7
libpcap.x86_64 14:1.5.3-11.el7
libpciaccess.x86_64 0:0.14-1.el7
libproxy.x86_64 0:0.4.11-11.el7
libpwquality.x86_64 0:1.2.3-5.el7
libselinux.x86_64 0:2.5-14.1.el7
libselinux-python.x86_64 0:2.5-14.1.el7
libselinux-utils.x86_64 0:2.5-14.1.el7
libsemanage.x86_64 0:2.5-14.el7
libsepol.x86_64 0:2.5-10.el7
libsoup.x86_64 0:2.62.2-2.el7
libss.x86_64 0:1.42.9-16.el7
libssh2.x86_64 0:1.8.0-3.el7
libstdc++.x86_64 0:4.8.5-39.el7
libstdc++-devel.x86_64 0:4.8.5-39.el7
libtasn1.x86_64 0:4.10-1.el7
libteam.x86_64 0:1.27-9.el7
libuser.x86_64 0:0.60-9.el7
libuuid.x86_64 0:2.23.2-61.el7_7.1
libxcb.x86_64 0:1.13-1.el7
linux-firmware.noarch 0:20190429-72.gitddde598.el7
logrotate.x86_64 0:3.8.6-17.el7
lsscsi.x86_64 0:0.27-6.el7
lua.x86_64 0:5.1.4-15.el7
lvm2.x86_64 7:2.02.185-2.el7_7.2
lvm2-libs.x86_64 7:2.02.185-2.el7_7.2
make.x86_64 1:3.82-24.el7
man-db.x86_64 0:2.6.3-11.el7
mariadb.x86_64 1:5.5.64-1.el7
mariadb-libs.x86_64 1:5.5.64-1.el7
microcode_ctl.x86_64 2:2.1-53.7.el7_7
mozjs17.x86_64 0:17.0.0-20.el7
ncurses.x86_64 0:5.9-14.20130511.el7_4
ncurses-base.noarch 0:5.9-14.20130511.el7_4
ncurses-libs.x86_64 0:5.9-14.20130511.el7_4
net-tools.x86_64 0:2.0-0.25.20131004git.el7
nettle.x86_64 0:2.7.1-8.el7
nspr.x86_64 0:4.21.0-1.el7
nss.x86_64 0:3.44.0-7.el7_7
nss-softokn.x86_64 0:3.44.0-8.el7_7
nss-softokn-freebl.x86_64 0:3.44.0-8.el7_7
nss-sysinit.x86_64 0:3.44.0-7.el7_7
nss-tools.x86_64 0:3.44.0-7.el7_7
nss-util.x86_64 0:3.44.0-4.el7_7
numactl-libs.x86_64 0:2.0.12-3.el7_7.1
openldap.x86_64 0:2.4.44-21.el7_6
openssh.x86_64 0:7.4p1-21.el7
openssh-clients.x86_64 0:7.4p1-21.el7
openssh-server.x86_64 0:7.4p1-21.el7
os-prober.x86_64 0:1.58-9.el7
p11-kit.x86_64 0:0.23.5-3.el7
p11-kit-trust.x86_64 0:0.23.5-3.el7
pam.x86_64 0:1.1.8-22.el7
parted.x86_64 0:3.1-31.el7
passwd.x86_64 0:0.79-5.el7
pciutils-libs.x86_64 0:3.5.1-3.el7
pcre.x86_64 0:8.32-17.el7
perl.x86_64 4:5.16.3-294.el7_6
perl-DBD-MySQL.x86_64 0:4.023-6.el7
perl-Getopt-Long.noarch 0:2.40-3.el7
perl-Git.noarch 0:1.8.3.1-21.el7_7
perl-Pod-Escapes.noarch 1:1.04-294.el7_6
perl-Socket.x86_64 0:2.010-4.el7
perl-libs.x86_64 4:5.16.3-294.el7_6
perl-macros.x86_64 4:5.16.3-294.el7_6
php.x86_64 0:5.4.16-46.1.el7_7
php-cli.x86_64 0:5.4.16-46.1.el7_7
php-common.x86_64 0:5.4.16-46.1.el7_7
php-gd.x86_64 0:5.4.16-46.1.el7_7
php-mysql.x86_64 0:5.4.16-46.1.el7_7
php-pdo.x86_64 0:5.4.16-46.1.el7_7
pinentry.x86_64 0:0.8.1-17.el7
plymouth.x86_64 0:0.8.9-0.32.20140113.el7.centos
plymouth-core-libs.x86_64 0:0.8.9-0.32.20140113.el7.centos
plymouth-scripts.x86_64 0:0.8.9-0.32.20140113.el7.centos
policycoreutils.x86_64 0:2.5-33.el7
polkit.x86_64 0:0.112-22.el7_7.1
postfix.x86_64 2:2.10.1-7.el7
ppp.x86_64 0:2.4.5-34.el7_7
procps-ng.x86_64 0:3.3.10-26.el7_7.1
python.x86_64 0:2.7.5-86.el7
python-libs.x86_64 0:2.7.5-86.el7
python-perf.x86_64 0:3.10.0-1062.18.1.el7
python-pycurl.x86_64 0:7.19.0-19.el7
python-pyudev.noarch 0:0.15-9.el7
python-slip.noarch 0:0.4.0-4.el7
python-slip-dbus.noarch 0:0.4.0-4.el7
python-urlgrabber.noarch 0:3.10-9.el7
readline.x86_64 0:6.2-11.el7
rpm.x86_64 0:4.11.3-40.el7
rpm-build-libs.x86_64 0:4.11.3-40.el7
rpm-libs.x86_64 0:4.11.3-40.el7
rpm-python.x86_64 0:4.11.3-40.el7
rsync.x86_64 0:3.1.2-6.el7_6.1
rsyslog.x86_64 0:8.24.0-41.el7_7.4
selinux-policy.noarch 0:3.13.1-252.el7_7.6
selinux-policy-targeted.noarch 0:3.13.1-252.el7_7.6
setup.noarch 0:2.8.71-10.el7
shadow-utils.x86_64 2:4.6-5.el7
shared-mime-info.x86_64 0:1.8-4.el7
sqlite.x86_64 0:3.7.17-8.el7_7.1
sudo.x86_64 0:1.8.23-4.el7_7.2
systemd.x86_64 0:219-67.el7_7.4
systemd-libs.x86_64 0:219-67.el7_7.4
systemd-sysv.x86_64 0:219-67.el7_7.4
tar.x86_64 2:1.26-35.el7
teamd.x86_64 0:1.27-9.el7
trousers.x86_64 0:0.3.14-2.el7
tuned.noarch 0:2.11.0-5.el7_7.1
tzdata.noarch 0:2019c-1.el7
unzip.x86_64 0:6.0-20.el7
util-linux.x86_64 0:2.23.2-61.el7_7.1
vim-common.x86_64 2:7.4.629-6.el7
vim-enhanced.x86_64 2:7.4.629-6.el7
vim-filesystem.x86_64 2:7.4.629-6.el7
vim-minimal.x86_64 2:7.4.629-6.el7
virt-what.x86_64 0:1.18-4.el7
wget.x86_64 0:1.14-18.el7_6.1
wpa_supplicant.x86_64 1:2.6-12.el7
xfsprogs.x86_64 0:4.5.0-20.el7
xz.x86_64 0:5.2.2-1.el7
xz-libs.x86_64 0:5.2.2-1.el7
yum.noarch 0:3.4.3-163.el7.centos
yum-plugin-fastestmirror.noarch 0:1.1.31-52.el7
zip.x86_64 0:3.0-11.el7
zlib.x86_64 0:1.2.7-18.el7
替代:
NetworkManager.x86_64 1:1.0.6-31.el7_2
grub2.x86_64 1:2.02-0.34.el7.centos
grub2-tools.x86_64 1:2.02-0.34.el7.centos
pygobject3-base.x86_64 0:3.14.0-3.el7
rdma.noarch 0:7.2_4.1_rc6-2.el7
完毕!
# cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
速度还是挺快的,几分钟就完事了,再查一下版本已经到7.7.1908了,为了彻底生效,还是重启一下吧。
继续升级PHP、MySQL(MariaDB)、Apache
数据库升级可能是最方便最顺利的,因为官方提供了yum源,按照步骤安装就行了。MariaDB官方链接点击这里
# cd /etc/yum.repos.d
# vim MariaDB.repo
# MariaDB 10.4 CentOS repository list - created 2020-04-29 05:43 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
# yum clean all
# yum makecache
# 备份数据库
# mysqldump -uroot -p --all-databases > /root/mariadb-55-backup.sql
Enter password:
# 卸载老版本
# yum remove mariadb*
Is this ok [y/d/N]: y
# 安装新版本
# yum install -y MariaDB-server MariaDB-client
Is this ok [y/d/N]: y
# systemctl start mariadb
# systemctl enable mariadb
# 升级数据库
# mysql_upgrade -uroot -p
Enter password:
......
Phase 7/7: Running 'FLUSH PRIVILEGES'
OK
# mysql -uroot -p
Enter password:
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]> exit
Bye
# mysql -V
mysql Ver 15.1 Distrib 10.4.12-MariaDB, for Linux (x86_64) using readline 5.1
Apache好久没用过了,官方版本好像是2.4.43(released 2020-04-01),但我几年前装的怎么就是2.4.6?本地Windows几年前装的WampServer中的版本就是2.4.37,不知道为什么,既然这样,就只能系统默认的2.4.6算了吧。
http://httpd.apache.org/download.cgi
# yum install httpd
Is this ok [y/d/N]: y
# systemctl start httpd
# systemctl enable httpd
继续升级PHP,主要是yum源不好找啊,为什么MariaDB官方能提供,其它的就不行呢?主要是centos更新了。
# rpm -qa |grep php
# yum remove -y php*
# yum info php //查询到可安装的php版本是5.4.16
# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# yum clean all
# yum makecache
# yum info php //还是没变,换一个repo源
试了阿里、清华、网易、epel多个源,可能只是官方的镜像吧,都是5.4.16。就算这样,更新centos系统了,也该升级一下相应软件的版本吧?不过centos8中好像默认是7.2以上了。
最后找到remi这个源,还挺丰富的,各个版本都有,安装也顺利,国外的,就是不熟悉,不知道来源安全与否。
# yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
Is this ok [y/d/N]: y
# cd /etc/yum.repos.d
# vim remi-php74.repo //安装哪个版本就修改哪个
将此区块enabled=0修改为enabled=1,保存退出。
[remi-php74]
name=Remi's PHP 7.4 RPM repository for Enterprise Linux 7 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/7/php74/$basearch/
#mirrorlist=https://rpms.remirepo.net/enterprise/7/php74/httpsmirror
mirrorlist=http://cdn.remirepo.net/enterprise/7/php74/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
# yum clean all
# yum makecache
# yum info php //此时可以看到php7.4.5的版本了。
# yum install php php-fpm
Is this ok [y/d/N]: y
# systemctl start php-fpm
# systemctl enable php-fpm
# systemctl restart httpd
成功!
发表回复