購買的雲服務器運行yum命令出現yum command not found。node
經過將雲主機自帶的yum和python卸載掉,而且同時須要關注/usr/bin/yum文件的首行解釋。我定義其爲"#!/usr/bin/python"python
1.卸載python:centos
1 rpm -qa|grep python|xargs rpm -e --allmatches --nodeps 2 whereis python|xargs rm -fr
2.卸載yum:服務器
1 rpm -qa|grep yum|xargs rpm -e --allmatches --nodeps 2 rm -rf /etc/yum.repos.d/* 3 whereis yum|xargs rm -fr
3.建立目錄python和yum用以存放rpm包:curl
1 mkdir /usr/local/src/python
2 mkdir /usr/local/src/yum
4.使用wget分別下載python以及yum的rpm包(注意:必定要和系統的版本號對應)url
(1)下載python的rpm包:spa
1 #cd /usr/local/src/python 進入目錄 2 3 #wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/python-2.7.5-34.el7.x86_64.rpm 4 #wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm 5 #wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/python-pycurl-7.19.0-17.el7.x86_64.rpm 6 #wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/python-devel-2.7.5-34.el7.x86_64.rpm 7 #wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/python-libs-2.7.5-34.el7.x86_64.rpm 8 #wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/python-urlgrabber-3.10-7.el7.noarch.rpm 9 #wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/rpm-python-4.11.3-17.el7.x86_64.rpm
(2)下載yum的rpm包:3d
1 #cd /usr/local/src/yum 2 3 #wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/yum-3.4.3-132.el7.centos.0.1.noarch.rpm 4 #wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm 5 #wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm
5.安裝python以及yum的rpm包code
(1)安裝python:blog
1 #cd /usr/local/src/python 2 3 #rpm -ivh python-* rpm-python-* 4 出現安裝包的依賴問題,此時以下解決便可: 5 6 #rpm -ivh python-* rpm-python-* --nodeps --force 7 --nodeps --force爲不考慮依賴包,強制安裝。 8 9 安裝完後便可運行python:
(2)安裝yum:
1 #cd /usr/local/src/yum 2 #rpm -ivh yum-*