Centos 使用 httpd 创建本地 yum 源
下载 Centos 完整 DVD iso
下载地址自行百度,这类我使用 centos 7.6 ,文件名:CentOS-7-x86_64-DVD-1810.iso
安装 httpd
yum install httpd -y
systemctl start httpd
systemctl enable httpd
挂载 iso
mkdir -p /var/www/html/centos7/os/x86_64
mount -o loop CentOS-7-x86_64-DVD-1810.iso /var/www/html/centos7/os/x86_64/
创建 repo 文件
$ vi /etc/yum.repos.d/Centos-Local.repo
[local]
name=Local Packages for Enterprise Linux 7.6
baseurl=http://172.16.0.20/centos7/os/x86_64/
enabled=1
gpgcheck=0
priority=1 # 优先级,1-99,越小优先级越大
测试
yum clean all
yum list
- 如果一切正确,就可以列出所有 rpm 包了
扩展
我们还可以手动创建 yum 的 repo 源
传输 rpm 文件
cd /var/www/html
mkdir dnf
cd dnf
# 在 dnf 目前上传相关 rpm 软件包
创建 repo metadata
cd /var/www/html/dnf
createrepo .
- 运行完成后会在当前目前下生成 repodata 目录
配置 repo 文件
$ vi /etc/yum.repos.d/dnf.repo
[dnf]
name=dnf
baseurl=http://172.16.0.20/dnf/
enabled=1
gpgcheck=0
测试使用
yum repolist dnf
yum install dnf