[笔记]CentOS如何启用单一的yum源

用法:

    yum --disablerepo=reponame  # 禁用源

    yum --enablerepo=reponame  # 启用源


# 以使用本地yum源安装php为例


# 查看可用的源

[test@localhost ~]$ yum repolist

Loaded plugins: fastestmirror, security

Determining fastest mirrors

.....省略....

repo id                         repo name                                 status

base                            CentOS-6 - Base                           6,696

c6-media                        CentOS-6 - Media                          6,575

extras                          CentOS-6 - Extras                            60

updates                         CentOS-6 - Updates                           94

repolist: 13,425


# 只是用本地yum源来安装

[test@localhost etc]$ sudo yum --disablerepo='*' --enablerepo=c6-media install php

Loaded plugins: fastestmirror, security

Setting up Install Process

Loading mirror speeds from cached hostfile

 * c6-media:    <--------注意

Resolving Dependencies

--> Running transaction check

# 以上还可写作

[test@localhost etc]$ sudo yum --disablerepo=* --enablerepo=c6-media install php

Loaded plugins: fastestmirror, security

Setting up Install Process

Loading mirror speeds from cached hostfile

 * c6-media:    <--------注意与之前输出的区别

Resolving Dependencies

--> Running transaction check


# 除了指定的源,其他存在的源也会启用

[test@localhost etc]$ sudo yum --enablerepo=c6-media install php                

[sudo] password for test:

Loaded plugins: fastestmirror, security

Setting up Install Process

Loading mirror speeds from cached hostfile

 * base: mirrors.yun-idc.com    <------注意与之前输出的区别

 * c6-media:

 * extras: mirrors.yun-idc.com

 * updates: mirrors.yun-idc.com

Resolving Dependencies

--> Running transaction check


# 所有的源都被禁用

[test@localhost etc]$ sudo yum --disablerepo='*' install php                   

Loaded plugins: fastestmirror, security

Setting up Install Process

Loading mirror speeds from cached hostfile

No package php available.    <------注意与之前输出的区别

Error: Nothing to do


你可能感兴趣的:(yum,源)