一、环境
CentOS 7.5
Apache/2.4.6
二、升级方法
执行命令显示httpd的详细信息:
# yum info httpd
输出以下信息:
- 已加载插件:fastestmirror, langpacks
- Repository base is listed more than once in the configuration
- Repository updates is listed more than once in the configuration
- Repository extras is listed more than once in the configuration
- Repository centosplus is listed more than once in the configuration
- Determining fastest mirrors
- * base: mirrors.aliyun.com
- * extras: mirrors.aliyun.com
- * updates: mirrors.aliyun.com
- 已安装的软件包
- 名称 :httpd
- 架构 :x86_64
- 版本 :2.4.6
- 发布 :80.el7.centos
- 大小 :9.4 M
- 源 :installed
- 来自源:anaconda
- 简介 : Apache HTTP Server
- 网址 :<a href="http://httpd.apache.org/" target="_blank">http://httpd.apache.org/</a>
- 协议 : ASL 2.0
- 描述 : The Apache HTTP Server is a powerful, efficient, and extensible
- : web server.
- 可安装的软件包
- 名称 :httpd
- 架构 :x86_64
- 版本 :2.4.6
- 发布 :89.el7.centos
- 大小 :2.7 M
- 源 :updates/7/x86_64
- 简介 : Apache HTTP Server
- 网址 :<a href="http://httpd.apache.org/" target="_blank">http://httpd.apache.org/</a>
- 协议 : ASL 2.0
- 描述 : The Apache HTTP Server is a powerful, efficient, and extensible
- : web server.
复制代码
可以看出,通过yum当前能安装的apache版本仍然是 2.4.6
安装CodeIT库,这个库提供了最新版本的Apache和Nginx
# yum install -y epel-release
# cd /etc/yum.repos.d && wget https://repo.codeit.guru/codeit.el`rpm -q --qf "%{VERSION}" $(rpm -q --whatprovides redhat-release)`.repo
# yum info httpd
输出如下内容:
- 已加载插件:fastestmirror, langpacks
- Repository base is listed more than once in the configuration
- Repository updates is listed more than once in the configuration
- Repository extras is listed more than once in the configuration
- Repository centosplus is listed more than once in the configuration
- Loading mirror speeds from cached hostfile
- * base: mirrors.aliyun.com
- * extras: mirrors.aliyun.com
- * updates: mirrors.aliyun.com
- CodeIT | 2.9 kB 00:00:00
- CodeIT/x86_64/primary_db | 117 kB 00:00:17
- 已安装的软件包
- 名称 :httpd
- 架构 :x86_64
- 版本 :2.4.6
- 发布 :80.el7.centos
- 大小 :9.4 M
- 源 :installed
- 来自源:anaconda
- 简介 : Apache HTTP Server
- 网址 :<a href="http://httpd.apache.org/" target="_blank">http://httpd.apache.org/</a>
- 协议 : ASL 2.0
- 描述 : The Apache HTTP Server is a powerful, efficient, and extensible
- : web server.
- 可安装的软件包
- 名称 :httpd
- 架构 :x86_64
- 版本 :2.4.39
- 发布 :2.codeit.el7
- 大小 :1.4 M
- 源 :CodeIT/x86_64
- 简介 : Apache HTTP Server
- 网址 :<a href="https://httpd.apache.org/" target="_blank">https://httpd.apache.org/</a>
- 协议 : ASL 2.0
- 描述 : The Apache HTTP Server is a powerful, efficient, and extensible
- : web server.
复制代码
可以看出,现在可以安装apache的最新版本 2.4.39
安装新版的apache:
# yum install httpd
报错信息如下:
- 错误:软件包:1:mod_ssl-2.4.39-2.codeit.el7.x86_64 (CodeIT)
- 需要:sscg >= 2.2.0
- 错误:软件包:mod_http2-1.14.1-1.codeit.x86_64 (CodeIT)
- 需要:libnghttp2.so.14()(64bit)
- 错误:软件包:mod_http2-1.14.1-1.codeit.x86_64 (CodeIT)
- 需要:libnghttp2 >= 1.21.1
- 您可以尝试添加 --skip-broken 选项来解决该问题
- 您可以尝试执行:rpm -Va --nofiles --nodigest
复制代码
从报错信息可以看出,需要 sscg (版本号>= 2.2.0)、libnghttp2.so.14()(64bit) 、libnghttp2 (版本号>= 1.21.1)3个软件包。
先下载相应软件包:
libnghttp2下载地址:https://www.51anidea.com/forum.php?mod=viewthread&tid=1039
sscg下载地址:https://www.51anidea.com/forum.php?mod=viewthread&tid=1038&extra=page%3D1
下载完之后,上传到服务器。
安装libnghttp2和sscg(此命令会自动安装相应的依赖包):
# yum localinstall libnghttp2-1.29.0-1.el7.x86_64.rpm sscg-2.5.1-1.el7.x86_64.rpm
安装新版的apache:
# yum install httpd
安装完后,验证新版本:
# httpd -v
Server version: Apache/2.4.39 (codeit)
Server built: May 31 2019 14:14:30
重启Apache:
# systemctl restart httpd
至此,Apache升级完毕。
|