加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

yum源仓库搭建

发布时间:2020-12-15 18:22:42 所属栏目:安全 来源:网络整理
导读:系统:centos7 一、安装nginx yum install -y nginx yum? install -y createrepo? ?安装建yum源仓库的工具,可以用来建立yum仓库 yum? install? -y yum-plugin-priorities 安装控制yum源更新优先级工具,这个工具可以用来控制进行yum源检索的先后顺序,建议

系统:centos7

一、安装nginx

yum install -y nginx

yum? install -y createrepo? ?安装建yum源仓库的工具,可以用来建立yum仓库
yum? install? -y yum-plugin-priorities 安装控制yum源更新优先级工具,这个工具可以用来控制进行yum源检索的先后顺序,建议可以用在client端。

二、配置nginx

/etc/nginx/nginx.conf

server{
listen 80;
autoindex on; autoindex_exact_size on; autoindex_localtime on;
}

默认index路径/usr/share/nginx/html

那么在html下面建立以下目录:

mkdir -p /usr/share/nginx/html/CentOS-YUM/CentOS/version_6.6/64bit/
mkdir -p /usr/share/nginx/html/CentOS-YUM/CentOS/version_7.0/64bit/
mkdir -p /usr/share/nginx/html/CentOS-YUM/Aliyun/version_6.6/64bit/
mkdir -p /usr/share/nginx/html/CentOS-YUM/Aliyun/version_7.0/64bit/

且不要忘记给目录增加可读和可执行权限,否则在web页面显示不出来。

chmod -R +x  /usr/share/nginx/html/

在web的index.html首页里面添加指向文件目录的超链接:

<p style="font-weight:bolder;color:green;font-size:30px;">ALL of the packages in the below:</p>
<br/>

<a href="http://159.138.1.77/CentOS-YUM/Aliyun">Aliyun</a><br/>

??????? These packagers from of CentOS ISO.<br/>

<a href="http://159.138.1.77/CentOS-YUM/CentOS">CentOS</a><br/>

??????? These packagers from of "Internet service provider".<br/>

<p style="font-weight:bolder;color:red;font-size:18px;">Please replace the file and fill in the following content:</p>
<p style="font-weight:bolder;color:blue;font-size:15px;">Way: /etc/yum.repos.d/CentOS-Base.repo</p>

重启nginx

systemctl restart nginx

?

三、修改当前系统yum来源repo文件

1.首先对此文件进行备份

cp -p /etc/yum.repos.d/CentOS-Base.repo    /etc/yum.repos.d/CentOS-Base.repo.bak

2.接下来去阿里云的官方网站下载阿里云的CentOS-Base.repo文件,如下所示:

mkdir -p /etc/yum.repos.d/Aliyun
wget -O /etc/yum.repos.d/Aliyun/CentOS-6.repo http://mirrors.aliyun.com/repo/Centos-6.repo wget -O /etc/yum.repos.d/Aliyun/CentOS-7.repo http://mirrors.aliyun.com/repo/Centos-7.repo

?

四、进行同步脚本的创建并执行同步

vim /etc/yum.repos.d/yum.reposync.sh

#!bin/bash
reposync -p /usr/share/nginx/html/CentOS-YUM/CentOS/version_7.0/64bit/
/usr/bin/sed -i "s/7/6/g" `grep 7 -rl /etc/yum.repos.d/CentOS-Base.repo`
reposync –p /usr/share/nginx/html/CentOS-YUM/CentOS/version_6.6/64bit/
cat /etc/yum.repos.d/Aliyun/CentOS-6.repo > /etc/yum.repos.d/CentOS-Base.repo
reposync –p /usr/share/nginx/html/CentOS-YUM/Aliyun/version_6.6/64bit/
/usr/bin/sed -i "s/6/7/g" `grep 6 -rl /etc/yum.repos.d/CentOS-Base.repo`
reposync –p /usr/share/nginx/html/CentOS-YUM/Aliyun/version_7.0/64bit/
cat /etc/yum.repos.d/CentOS-Base.repo.bak > /etc/yum.repos.d/CentOS-Base.repo

chmod +x? /etc/yum.repos.d/yum.reposync.sh

然后执行脚本

sh yum.reposync.sh

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读