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

admin 2023年12月14日13:38:18评论10 views字数 3865阅读12分53秒阅读模式

0x01 前言

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

0x02 源代码安装Python3

下载Python3软件包

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

安装Python3

先解压

tar zxvf Python-3.5.4.tgz

CentOS 5.x 安装Python3和yum源配置
然后进入

cd Python-3.5.4

编译安装

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

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

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/

记得修改钱备份你的文件

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

然后

vi /etc/yum.repos.d/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=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> 

最后执行

yum makecache
yum update

等待更新就行了

0x04 结束

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

0x05 参考

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


  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2023年12月14日13:38:18
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   CentOS 5.x 安装Python3和yum源配置https://cn-sec.com/archives/2298299.html

发表评论

匿名网友 填写信息