[筆記]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


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章