一、前提
先备份之前httpd的配置,主要是对应的端口。
卸载旧版的httpd。
时间:2022-11-01
系统:Centos 7.6
默认版本:Apache 2.4.6
这时候最新的apache版本时2.4.54
https://httpd.apache.org/download.cgi
二、更新
- 查找Centos上软件库里的httpd版本:
yum info httpd
(显示默认软件库中只有2.4.6版本的apache)
- CodeIT库提供了最新版本的服务器软件(Apache & Nginx)。这个库依赖 epel 。
先要安装 epel-release
yum install -y epel-release
- 安装CodeIT库
cd /etc/yum.repos.d && wget https://repo.codeit.guru/codeit.el7.repo `rpm -q --qf "%{VERSION}" $(rpm -q --whatprovides redhat-release)`.repo
/etc/yum.repos.d目录下新增了文件: codeit.el7.repo 内容如下:
[CodeIT]
name=CodeIT repo
baseurl=https://repo.codeit.guru/packages/centos/7/$basearch
enabled=1
gpgkey=https://repo.codeit.guru/RPM-GPG-KEY-codeit
gpgcheck=1
- 再次查询可以安装的版本
yum info httpd
(显示有2.4.54版本)
- 安装新的httpd
yum install httpd
systemctl start httpd
systemctl enable httpd
httpd -v
三、遇见问题
- 安装后不能运行(提示缺少libpcre2-8.so.0)
find / -name libpcre2-8.so.0 # 找到文件的位置,我的系统中有这个文件,只是不能识别
cp libpcre2-8.so.0文件的位置 /usr/lib64/ # 复制到/usr/lib64/这个目录
systemctl restart httpd # 再次运行可以启动了