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
。这个时候,参考这篇文章,可以获得解决。这里列出几个关键点:
- 使用官方命令,编译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版本。
- 先完成支线任务编译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
- 升级Apache HTTP Server到最新版本
bash
rpm -U httpd-2.4.60-1.x86_64.rpm --replacefiles
- 验证版本号
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.
- 重启Apache HTTP Server
bash
systemctl status httpd.service