CentOS7.9下yum升级Apache HTTP Server2.4.6到2.4.60

1、CentOS7.9系统默认的Apache版本

在CentOS7.9上,如果使用yum安装Apache HTTP Server是最多到2.4.6版本的,这是因为el7下官方仓库的最高版本就是2.4.6,证据如下:

bash 复制代码
$ yum info httpd
......
Installed Packages
Name        : httpd
Arch        : x86_64
Version     : 2.4.6
Release     : 99.el7.centos.1
Size        : 9.4 M
Repo        : installed
From repo   : updates
Summary     : Apache HTTP Server
URL         : http://httpd.apache.org/
License     : ASL 2.0
Description : The Apache HTTP Server is a powerful, efficient, and extensible
            : web server.

2、借助第三方平台可否升级

根据这一篇,可以找到第三方的一个开源库:https://repo.codeit.guru/packages/centos/8/x86_64/,但是很可惜,这个开源库最低从el8开始,没有对el7提供支持,或者准确的说el7已经过时了,所以这个第三方平台升级行不通。

3、借助官方平台可否升级

找到CentOS官方镜像:http://mirror.centos.org/centos/7/os/x86_64/Packages/,但是很遗憾,依然404。官方也是最低从8开始,7已经过时了。

4、寻根索源找到Apache官方解决方案

对于没有现成rpm包提供的平台,可以通过rpmbuild编译生成。地址参考这里
不过编译过程,不会那么顺利,需要随时根据提示,安装对应的依赖,在这个过程中,又有个关键的点是,报错:找不到文件:httpd-2.4.60-1.x86_64/usr/lib64/httpd/modules/mod_mpm_event.so。这个时候,参考这篇文章,可以获得解决。这里列出几个关键点:

  1. 使用官方命令,编译rpm
bash 复制代码
rpmbuild -tb httpd-2.4.60.tar.bz2

期间运行报错找不到文件:httpd-2.4.60-1.x86_64/usr/lib64/httpd/modules/mod_mpm_event.so,是arp(Apache Portable Runtime)版本低,下载获取最新的1.7.4版本。

  1. 先完成支线任务编译apr,再继续编译apache。编译成功。
bash 复制代码
tar xvjf apr-1.7.4.tar.bz2
cp apr-1.7.4/apr.spec ../SPECS/
cd ../SPECS/
rpmbuild -ba apr.spec
=====编译apr完成====
cd ../RPMS/x86_64/
yum localinstall apr-1.7.4-1.x86_64.rpm apr-devel-1.7.4-1.x86_64.rpm
=====本地安装apr完成====
cd ../../SPECS/
rpmbuild -ba httpd.spec
=====编译httpd完成=====
cd ../RPMS/x86_64/
ll
total 11592
-rw-rw-r-- 1 fibre fibre  112588 Jul  2 15:40 apr-1.7.4-1.x86_64.rpm
-rw-rw-r-- 1 fibre fibre  479112 Jul  2 15:40 apr-debuginfo-1.7.4-1.x86_64.rpm
-rw-rw-r-- 1 fibre fibre  883796 Jul  2 15:40 apr-devel-1.7.4-1.x86_64.rpm
-rw-rw-r-- 1 fibre fibre 1442512 Jul  2 15:46 httpd-2.4.60-1.x86_64.rpm
-rw-rw-r-- 1 fibre fibre 3989440 Jul  2 15:46 httpd-debuginfo-2.4.60-1.x86_64.rpm
-rw-rw-r-- 1 fibre fibre  213624 Jul  2 15:46 httpd-devel-2.4.60-1.x86_64.rpm
-rw-rw-r-- 1 fibre fibre 4423920 Jul  2 15:46 httpd-manual-2.4.60-1.x86_64.rpm
-rw-rw-r-- 1 fibre fibre   81068 Jul  2 15:46 httpd-tools-2.4.60-1.x86_64.rpm
-rw-rw-r-- 1 fibre fibre   48384 Jul  2 15:46 mod_authnz_ldap-2.4.60-1.x86_64.rpm
-rw-rw-r-- 1 fibre fibre   48328 Jul  2 15:46 mod_lua-2.4.60-1.x86_64.rpm
-rw-rw-r-- 1 fibre fibre   25300 Jul  2 15:46 mod_proxy_html-2.4.60-1.x86_64.rpm
-rw-rw-r-- 1 fibre fibre   99136 Jul  2 15:46 mod_ssl-2.4.60-1.x86_64.rpm
  1. 升级Apache HTTP Server到最新版本
bash 复制代码
rpm -U httpd-2.4.60-1.x86_64.rpm --replacefiles
  1. 验证版本号
bash 复制代码
$ yum info httpd
......
Loaded plugins: changelog, fastestmirror, langpacks
Loading mirror speeds from cached hostfile
base                                                                                                                                                                                                                     | 2.9 kB  00:00:00     
Not using downloaded base/repomd.xml because it is older than what we have:
  Current   : Mon Mar 18 13:00:09 2024
  Downloaded: Mon Oct 17 08:02:38 2022
centos-sclo-rh                                                                                                                                                                                                           | 2.9 kB  00:00:00     
centos-sclo-sclo                                                                                                                                                                                                         | 2.9 kB  00:00:00     
elrepo                                                                                                                                                                                                                   | 2.9 kB  00:00:00     
epel                                                                                                                                                                                                                     | 2.9 kB  00:00:00     
extras                                                                                                                                                                                                                   | 2.9 kB  00:00:00     
Not using downloaded extras/repomd.xml because it is older than what we have:
  Current   : Fri Apr  5 17:49:29 2024
  Downloaded: Mon Oct 17 08:02:40 2022
remi                                                                                                                                                                                                                     | 2.9 kB  00:00:00     
updates                                                                                                                                                                                                                  | 2.9 kB  00:00:00     
Not using downloaded updates/repomd.xml because it is older than what we have:
  Current   : Sat Jun 22 00:30:50 2024
  Downloaded: Mon Oct 17 08:03:51 2022
Installed Packages
Name        : httpd
Arch        : x86_64
Version     : 2.4.60
Release     : 1
Size        : 4.4 M
Repo        : installed
Summary     : Apache HTTP Server
URL         : http://httpd.apache.org/
License     : Apache License, Version 2.0
Description : Apache is a powerful, full-featured, efficient, and freely-available
            : Web server. Apache is also the most popular Web server on the
            : Internet.
  1. 重启Apache HTTP Server
bash 复制代码
systemctl status httpd.service
相关推荐
迈威通信1 天前
迈威通信从送快递角度教你分清网络二层和三层
网络·网络协议·智能路由器·信息与通信
郝亚军1 天前
根据Sec-WebSocket-Key计算Sec-WebSocket-Accept
网络·websocket·网络协议
Kaede61 天前
深入探索 WebSocket:构建实时应用的核心技术
网络·websocket·网络协议
web前端神器1 天前
记录一下node后端写下载https的文件报错,而浏览器却可以下载。
网络协议·http·https
三项超标1 天前
AI入坑: Trae 通过http调用.net 开发的 mcp server
网络·网络协议·http
绵绵细雨中的乡音1 天前
HTTP 协议详解
网络·网络协议·http
耐达讯通信技术1 天前
惊爆!耐达讯自动化RS485转Profinet,电机连接的“逆天神器”?
运维·网络·人工智能·科技·网络协议·自动化
JJ1M81 天前
http问题汇总
网络·网络协议·http
喂完待续1 天前
【Big Data】云原生与AI时代的存储基石 Apache Ozone 的技术演进路径
云原生·架构·apache·big data·序列晋升
檀越剑指大厂2 天前
【网络协议系列】CLOSE_WAIT状态解释
网络·网络协议