欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

在CentOS上设置本地YUM源的方法

最编程 2024-02-14 22:26:50
...

一.简介

centos6系列于2020年11月份已经停止提供服务,现在各大镜像源已经关闭centos6的yum源,需要下载镜像后在本地搭建yum源方便使用。

最好将镜像下载后传到OSS中,这样从阿里云机器拉取就快很多了,一般的服务器带宽都,直接下载会非常的慢。

下载站:https://man.linuxde.net/download/ 选择bin-DVD版本,这个里面包含的包最多。遗憾的是6系列的epel源是应该没法用了。

二.操作

1.创建挂载目录 mkdir /yum-source

2.挂载 mount -o loop rhel-server-6.9-x86_64-dvd.iso /yum-source

3.本地yum源 rm -rf /etc/yum.repos.d/* vim /etc/yum.repos.d/centos.repo

  1. [base-local]
  2. name=CentOS6.8-local
  3. baseurl=file:///yum-source
  4. enabled=1
  5. gpgcheck=0

4.清理使用

yum clean all

yum makecache

三.对外提供yum服务

本地服务只能本机用,需要其它机器也用

1.安装nginx,当然httpd、ftp也行 yum -y install nginx yum install createrepo -y

2.配置挂载目录,添加一个server段 vim /etc/nginx/nginx.conf

  1. server {
  2. listen 8082;
  3. server_name localhost;
  4. location / {
  5. root /yum-source;
  6. index index.html;
  7. }
  8. error_page 500 502 503 504 /50x.html;
  9. location = /50x.html {
  10. root html;
  11. }
  12. }

3.检测配置文件,并启动nginx nginx -t nginx

4.测试是否有服务提供了,应该会显示一个目录结构 curl http://127.0.0.1:8082

5.其它服务器配置yum源,就是将地址换了而已 rm -rf /etc/yum.repos.d/* vim /etc/yum.repos.d/centos.repo

  1. [base-local]
  2. name=CentOS6.8-local
  3. baseurl=http://172.16.1.4:8082
  4. enabled=1
  5. gpgcheck=0

6.清理使用

yum clean all

yum makecache

推荐阅读