系统环境:Redhat 8.8
yum镜像:Redhat 8.8
Apache(httpd):
一、系统挂载镜像
[root@localhost ~]# lsblk
[root@localhost ~]# mkdir /tmp/cdrom
[root@localhost ~]# mount /dev/sr0 /tmp/cdrom/[root@localhost ~]# df -h
将镜像中文件复制到 /iso/rhel-8.8-x86_64下。
[root@localhost ~]#mkdir -p /iso/rhel-8.8-x86_64
[root@localhost ~]#cp -R /tmp/cdrom/* /iso/rhel-8.8-x86_64/
二、服务器自身配置yum源
[root@localhost ~]#cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# touch redhat.repo
[root@localhost yum.repos.d]# vim redhat.repo
[base]
name=BaseOS
baseurl=file:///iso/rhel-8.8-x86_64/BaseOS
enable=1
gpgcheck=0[AppStream]
name=AppStream
baseurl=file:///iso/rhel-8.8-x86_64/AppStream
enable=1
gpgcheck=0[root@localhost yum.repos.d]# yum clean all
[root@localhost yum.repos.d]# yum makecache
三、安装配置 httpd
[root@localhost yum.repos.d]# yum install -y httpd
已更新安装的产品。
已安装:
apr-1.6.3-12.el8.x86_64
apr-util-1.6.1-6.el8.x86_64
apr-util-bdb-1.6.1-6.el8.x86_64
apr-util-openssl-1.6.1-6.el8.x86_64
httpd-2.4.37-56.module+el8.8.0+18556+a66138c1.4.x86_64
httpd-filesystem-2.4.37-56.module+el8.8.0+18556+a66138c1.4.noarch
httpd-tools-2.4.37-56.module+el8.8.0+18556+a66138c1.4.x86_64
mod_http2-1.15.7-8.module+el8.8.0+18556+a66138c1.3.x86_64
redhat-logos-httpd-84.5-1.el8.noarch完毕!
编辑http的配置文件,修改默认目录为要发布镜像的目录 /iso。
[root@localhost conf]# cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak
[root@localhost conf]# vim httpd.conf
删除 httpd 的默认主页(此处为将默认主页改名))
[root@localhost conf]# mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf.bak
修改 /iso 目录归属为 apache
[root@localhost /]# chown -R apache.apache iso
四、关闭防火墙
[root@localhost /]#systemctl stop firewalld
[root@localhost /]#systemctl disable firewalld
[root@localhost /]#setenforce 0
五、重启 httpd 服务后访问
[root@localhost /]# systemctl restart httpd
六、客户端配置
在客户端编辑 repo 文件,指向镜像源位置。
注意:repo 文件中位置为网页能访问到的位置:http://ip/rhel-8.8-x86_64/。而不是系统中实际位置:http://ip/iso/rhel-8.8-x86_64/。切记,否则会报错。
[root@localhost /]#yum makecache
附录:第6步配置路径错误时报错信息:
BaseOS 31 kB/s | 196 B 00:00
Errors during downloading metadata for repository 'BaseOS':
- Status code: 404 for http://10.x.x.x/iso/rhel-8.8-x86_64/BaseOS/repodata/repomd.xml (IP: 10.1.81.194)
错误:为仓库 'BaseOS' 下载元数据失败 : Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried