---
title: "把Centos的yum源更换为国内的阿里云源"
author: "breezylee"
date: "2017-09-15T09:07:53Z"
tags: []
categories: ["操作系统"]
slug: "centos-yum"
draft: false
lastmod: "2017-09-15T09:07:53Z"
id: 2393329
url: "https://breezylee.iteye.com/blog/2393329"
---

有时用yum install安装组件的时候， 查不到软件源，报各种404错误。此时操作系统默认是去.edu教育网去找的软件，如果教育网没有更新软件此时用yum install则无法安装。解决方法是把yum源更改为啊里云的资源。如果啊里云上也没有相应的软件，那就呵呵了。

### 1、备份

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

### []()2、下载新的CentOS-Base.repo 到/etc/yum.repos.d/

 

#### []()CentOS 5

`wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo`

 

#### []()CentOS 6

`wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo`

 

#### []()CentOS 7

`wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo`

### []()3、之后运行yum makecache生成缓存