Centos下安装yum(完整教程)
生活随笔
收集整理的這篇文章主要介紹了
Centos下安装yum(完整教程)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
在安裝yum的時候發現網上的方法參差不齊,不是很完整,以下是個人親測,同時是總結出的最方便的方法,希望能幫助到大家!
- 查看已安裝的yum
rpm -qa|grep yum
- 刪除已有的yum
rpm -aq|grep yum|xargs rpm -e --nodeps
- 下載以下安裝包
wget http://tel.mirrors.163.com/centos/7/os/x86_64/Packages/python-2.7.5-89.el7.x86_64.rpm
wget http://tel.mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget http://tel.mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm
wget http://tel.mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://tel.mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
如果找不到以上版本,可以到http://tel.mirrors.163.com/centos/7/os/x86_64/Packages/下載最新版本
- 安裝
rpm -ivh python-2.7.5-89.el7.x86_64.rpm python-iniparse-0.4-9.el7.noarch.rpm --nodeps --force
rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm --nodeps --force
rpm -ivh yum-3.4.3-168.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm --nodeps --force
- 更改yum源
-
到該網站http://mirrors.163.com/.help/centos.html下載配置文件,重命名為CentOS-Base.repo
-
首先備份/etc/yum.repos.d/CentOS-Base.repo
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup -
下載對應版本repo文件, 放入/etc/yum.repos.d/(操作前請做好相應備份)
Centos7
Centos6
Centos5
-
運行以下命令生成緩存
yum clean all yum makecache -
-
修改配置文件
- 運行一下命令打開CentOS-Base.repo文件
cd /etc/yum.repos.d vim CentOS-Base.repo也可以通過Xftp7軟件編輯,更加方便快捷
- 將以下配置更換Centos-Base.repo里的內容
# CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # #[base] name=CentOS-$releasever - Base #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7#released updates [updates] name=CentOS-$releasever - Updates # mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7#additional packages that may be useful [extras] name=CentOS-$releasever - Extras # mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7#additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus # mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7- 配置完成后更新緩存
yum clean all yum makecache
- 完成以上步驟就可以成功在Linux安裝上yum啦
總結
以上是生活随笔為你收集整理的Centos下安装yum(完整教程)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: P2151 [SDOI2009]HH去散
- 下一篇: 【C语言进阶】最常用的库函数大全——从入