Skip to content

CentOS 7 进行服务器完善和升级

系统软件安装以及升级

基础工具安装

shell
# normal tools
yum install wget vim yum-utils gcc git
# autojump
yum install autojump
# zip
yum install zip unzip

rockylinux 9

shell
dnf install autojump

升级 curl 为最新版本

由于 CentOS 7 内置的 curl 和 libcurl 源为较旧的版本 7.29/7.68,不支持一些新特性且有安全性问题,所以需要更新一下

快捷安装命令, 此命令不对系统进行强制性更新

shell
/bin/bash -c "$(curl -fsSL https://i.wulicode.com/op/file/centos-curl.sh?version=8.1.1)"

安装完成, 查看版本

shell
curl -V
curl 8.1.1 (x86_64-pc-linux-gnu) libcurl/8.1.0 OpenSSL/1.0.2k-fips zlib/1.2.7
Release-Date: 2023-05-17
Protocols: dict file ftp ftps gopher gophers http https imap imaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS HSTS HTTPS-proxy IPv6 Largefile libz NTLM NTLM_WB SSL UnixSockets

源添加和更换

CentOS 镜像

shell
# 更换为 aliyun 提高下载速度, 设置aliyun库
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

Remi 镜像

Remi repository 是包含最新版本 PHP 和 MySQL 包的 Linux 源,由 Remi 提供维护

官方源 : https://rpms.remirepo.net/

Aliyun : https://developer.aliyun.com/mirror/remi

shell
# 设置 remi 库 , 二选一
# official
yum install http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

# aliyun mirror
yum install https://mirrors.aliyun.com/remi/enterprise/remi-release-7.rpm

系统升级

shell
# 更新元数据
yum makecache

# 更新和升级
yum update
yum upgrade

关闭 Seliunx

这里遇到一个坑, 如果不关闭 SELinux, 可能会遇到开发的坑.检查 SELinux 是否在运行:

shell
getenforce

下次重启前禁用 SELinux:

shell
setenforce Permissive

重新启动 Nginx,看看问题是否仍然存在。如果您想永久更改 Selinux 设置,可以编辑 /etc/sysconfig/selinux

QA:

如果提示缺少依赖 libnghttp2.so.14()(64bit)

错误:软件包:libcurl-7.75.0-1.1.cf.rhel7.x86_64 (city-fan.org) > 需要:libnghttp2.so.14()(64bit)

shell
rpm -ivh https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/l/libnghttp2-1.33.0-1.1.el7.x86_64.rpm

这里地址是 centos7 版本, 如果是其他系统, 可以在一下路径自己寻找 https://dl.fedoraproject.org/pub/epel/