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
相关推荐
无奈笑天下18 小时前
银河麒麟桌面上USB打印机无法打印问题标准处理流程
linux·运维·网络协议
张小姐的猫21 小时前
【基于 WebSocket 的多用户网页五子棋】—— 整合封装服务器模块设计实现1️⃣
服务器·websocket·网络协议
程序员韩星1 天前
OpenAI 兼容接口返回 404,先查请求地址,再查模型名
前端·人工智能·http
无奈笑天下2 天前
银河麒麟上DHCP无法获取IP地址问题处理
linux·运维·服务器·网络协议
nice_lcj5202 天前
【从零理解计算机网络 · 03】IP 与端口:数据怎么找到机器,又怎么找到进程
后端·网络协议·计算机网络·面试·ip地址·端口·127.0.0.1
小乖写代码2 天前
帧协议(TCP) · TCP Framing
网络·网络协议·tcp/ip·tcp
如夏倾城2 天前
VRRP(虚拟路由器冗余协议Virtual Router Redundancy Protocol)
网络·python·网络协议·安全·智能路由器·负载均衡·信息与通信
张小姐的猫3 天前
【基于 WebSocket 的多用户网页五子棋】—— 认识第三方库Websocketpp
网络·websocket·网络协议
张小姐的猫3 天前
【基于 WebSocket 的多用户网页五子棋】—— 游戏匹配对战设计
websocket·网络协议·游戏
我不会插花弄玉5 天前
5.应⽤层协议HTTP【由浅入深-网络】
http