centos7.4服务器系统下如何重装python2.7.5及yum

因一次意外,不小心卸掉了服务器自带的python,导致yam不可用,故写此博客记录一番安装踩坑经历。
1.创建目录python和yum用以存放rpm包

  mkdir /usr/local/src/python
  mkdir /usr/local/src/yum

2.下载python的rpm包:
2.1 cd /usr/local/src/python 进入目录
下载路径:http://vault.centos.org/7.4.1708/os/x86_64/Packages/(注意centos版本一定要正确,我的版本是7.4.1708)
下载的包有:

wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-2.7.5-58.el7.x86_64.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-devel-2.7.5-58.el7.x86_64.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-libs-2.7.5-58.el7.x86_64.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-urlgrabber-3.10-8.el7.noarch.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/rpm-python-4.11.3-25.el7.x86_64.rpm
	2.2安装python:

rpm -ivh python-* rpm-python-*
出现安装包的依赖问题时,解决方案:

 rpm -ivh python-* rpm-python-* --nodeps --force
	注:    --nodeps --force为不考虑依赖包,强制安装
	2.3检测是否安装成功
	          `python -V`---检测安装的版本号

3.下载yum的rpm包
3.1进入目录 cd /usr/local/src/yum
3.2 下载yum的rpm包:(注意系统的版本)

wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/yum-3.4.3-154.el7.centos.noarch.rpm

3.3

rpm -ivh yum-*
cd  /etc/yum.repos.d
yum clean all
yum makecache

至此,python2.7.5及yum就安装好了。
亲测可用。

你可能感兴趣的:(安装手册)