centos6 搭建在线yum源

一.搭建在线yum源的优势

1.架设自己的yum源,节省带宽
2.避免通过网络访问延迟
3.对于有联网限制的服务器
二.搭建步骤
1.安装nginx

yum install nginx -y
修改配置文件
vim /usr/local/nginx/conf/nginx.conf
server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   /rpm;
            index  index.html index.htm;
            autoindex on;
        }
/usr/local/nginx/sbin/nginx   ##启动nginx

2.搭建国内yum源
(1)备份原始yum源

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
yum clear all
yum repolist

3.同步网络yum源
(1)创建目录

 mkdir /rpm

(2)安装工具包

 yum -y install yum-utils
 cd /rpm
 reposync -r base   ##缓存网络源到本地

(3)扫描yum源配置目录

createrepo  base/Packages/

至此本地yum源搭建成功

三 . 测试
(1)备份自带yum 源

  mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

(2)配置yum源
这里写图片描述

猜你喜欢

转载自blog.csdn.net/bittersweet0324/article/details/77803933