背景
之前公司的Zabbix平台是4.2版本的,版本有点老,很多模板也是用不了,于是使用了Centos Stream 8重构了一下Zabbix平台,都是使用YUM安装的(除了数据库外),漏扫出现了很多httpd的漏洞,查阅了一些httpd的升级教程基本以源码编译安装居多,基于YUM的httpd不想使用编译安装,遂总结下rpm包的升级方式。
参考:Apache httpd 安全漏洞处理-升级httpd版本_httpd升级_大新新大浩浩的博客-CSDN博客
一、现状
查看Httpd当前版本,Server version: Apache/2.4.37 (CentOS Stream) |
[root@test01 ~]# httpd -v
Server version: Apache/2.4.37 (CentOS Stream)
Server built: Aug 17 2023 14:07:36
当前Httpd最新版本为2.4.58,是我们要升级的最新版本,之前的版本均存在漏洞
二、使用codeit库升级Apache
1、安装epel-release
cd /etc/yum.repos.d
1)安装 epel 配置包
yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
2)将 repo 配置中的地址替换为阿里云镜像站地址
sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*
2、下载codeit的repo文件
cd /etc/yum.repos.d
wget https://repo.codeit.guru/codeit.el`rpm -q --qf "%{VERSION}" $(rpm -q --whatprovides redhat-release)`.repo
我参照此方法去下载的时候报错ERROR 404: Not Found.,因为我的Centos Stream 8系统使用命令查出来是8.6,https://repo.codeit.guru此网站没有8.6小版本的目录,所以我直接下载codeit.el8.repo
rpm -q --qf "%{VERSION}" $(rpm -q --whatprovides redhat-release)
8.6
wget https://repo.codeit.guru/codeit.el8.repo
3、查看Httpd可更新版本,发现还是2.4.37的版本(不知道什么原因,有大佬知道的可以解释一下)
[root@test01 yum.repos.d]# dnf info httpd
Warning: failed loading '/etc/yum.repos.d/CentOS-Base.repo', skipping.
CodeIT repo 81 kB/s | 186 kB 00:02
Extra Packages for Enterprise Linux 8 - x86_64 7.2 MB/s | 16 MB 00:02
Extra Packages for Enterprise Linux 8 - Next - x86_64 632 kB/s | 368 kB 00:00
Last metadata expiration check: 0:00:01 ago on Tue 28 Nov 2023 09:07:54 AM CST.
Installed Packages
Name : httpd
Version : 2.4.37
Release : 62.module_el8+657+88b2113f
Architecture : x86_64
Size : 4.3 M
Source : httpd-2.4.37-62.module_el8+657+88b2113f.src.rpm
Repository : @System
From repo : appstream
Summary : Apache HTTP Server
URL : https://httpd.apache.org/
License : ASL 2.0
Description : The Apache HTTP Server is a powerful, efficient, and extensible
: web server.
三、下载RPM包更新
1、下载安装包更新Httpd
wget https://repo.codeit.guru/packages/centos/8/x86_64/httpd-2.4.58-1.module_codeit.codeit.el8.x86_64.rpm
wget https://repo.codeit.guru/packages/centos/8/x86_64/httpd-filesystem-2.4.58-1.module_codeit.codeit.el8.noarch.rpm
wget https://repo.codeit.guru/packages/centos/8/x86_64/httpd-tools-2.4.58-1.module_codeit.codeit.el8.x86_64.rpm
dnf localupdate httpd*.rpm -y
2、重启Httpd服务,查看版本
systemctl restart httpd
httpd -v
Server version: Apache/2.4.58 (codeit)
Server built: Oct 19 2023 10:22:07