CentOS 5.x 安装 Python3 和 yum 源配置

0x01 前言

技能大赛的题目里面用的是 CentOS 的系统,本来觉得没什么,居然要装上 Python3 的版本,尝试了各种办法去下载 python.
中间用了 curlwget 的下载方式,提示,说不能建立 SSL,办法就是更新 wget 这个工具,我想我还是自己下载吧。

然而浏览器也是

0x02 源代码安装 Python3

下载 Python3 软件包

老系统就安装那么新的版本了,就选择了一个 3.5 的,在实体机下载的,因为浏览器也不支持 ssl,只能在实体机下载了软件包然后拉到虚拟机里面。
下载地址:https://www.python.org/downloads/release/python-355/
把文件放到用户的主目录,然后切换到 root。

安装 Python3

先解压

1
tar zxvf Python-3.5.4.tgz


然后进入

1
cd Python-3.5.4

编译安装

1
./configure prefix=/usr/local/python3
1
make && make install

这里需要等一段时间,安装好之后,因为 CentOS 原本就自带了 Python2 的版本,所以我们可以软链到 /usr/bin 的目录下,并改名为 python3。

1
ln -s /usr/local/python3/bin/python3 /usr/bin/python3

安装完成后

0x03 配置 yum 源

但是很多库文件要下载,pip 也要安装,网上都是用 yum 安装 pip 的,所以只得更新下 yum 源了。
我开始是去百度找的,但是那些都过期了,就去官网找。
http://mirror.centos.org/centos/5.5/readme
里面只有一个 readme, 内容是

This directory (and version of CentOS) is deprecated. For normal users,
you should use /5/and not /5.5/in your path. Please see this FAQ
concerning the CentOS release scheme:
https://wiki.centos.org/FAQ/General
If you know what you are doing, and absolutely want to remain at the 5.5
level, go to http://vault.centos.org/for packages. Please keep in mind that 5.5 no longer gets any updates

然后我又去找 5 版本的目录 http://mirror.centos.org/centos/5/readme

This directory (and version of CentOS) is depreciated.
CentOS-5 is now past EOL
You can get the last released version of centos 5.11 here:
http://vault.centos.org/5.11/
Please NOTE: this is not being maintained for security since moving to Vault.
It will have security issues, you should upgrade to a new version instead.

说已经弃用了,叫我去这里找 http://vault.centos.org/5.11/

记得修改钱备份你的文件

1
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

然后

1
vi /etc/yum.repos.d/CentOS-Base.repo

输入一下内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# 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=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=http://vault.centos.org/5.11/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5


#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
baseurl=http://vault.centos.org/5.11/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5


#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
baseurl=http://vault.centos.org/5.11/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5




#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=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
baseurl=http://vault.centos.org/5.11/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5




#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
baseurl=http://vault.centos.org/5.11/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5</span></strong></span>

最后执行

1
yum makecache
1
yum update

等待更新就行了

0x04 结束

又鼓捣了一个下午,每周一洞的文章还没写,现在比赛时间太紧了。

0x05 参考

https://blog.csdn.net/qq_36357820/article/details/77732656