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

前端之家收集整理的这篇文章主要介绍了[笔记]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

原文链接:https://www.f2er.com/centos/382220.html

猜你在找的CentOS相关文章