centos 安装或更新最新版本软件包(git python etc)的方法 SCL IUS
使用centos 经常发现官方提供的软件包版本过低,很多时候大家会选择下载源码自行编译,带来了很多麻烦。
centos安装最新版本软件包,例如git,python等,可以通过红帽官方提供的software collection,或者社区提供的ius实现。
SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。SCL
scl不是一个简单的包管理工具,而是类似python的virtualenv 。它可以支持系统同时安装多个版本的软件,然后通过scl enable命令来激活相应软件环境,而不会对原始的软件环境产生影响。
以git安装和启用为例:
yum install centos-release-scl
yum install rh-git29
scl enable rh-git29 bash ##激活git的打开bash
git --version
但是对于我们而言,如果不需要这么复杂的虚拟环境功能,单纯想要使用其提供的最新版本软件,可以通过 source scl_source enable 命令实现。
如果需要系统重启后,能够自动启动最新版本软件环境,可进行以下配置:
#通过bash环境来设定,仅对特定用户启用
vi ~/.bashrc # or ~/.bash_profile
source scl_source enable rh-git29
或者(推荐)
#对全局用户启用
vi /etc/profile.d/enable_scl.sh
#!/bin/bash
source scl_source enable rh-git29
参考:
https://www.softwarecollections.org/en/docs/
http://xmodulo.com/enable-software-collections-centos.html
https://unix.stackexchange.com/questions/175851/how-to-permanently-enable-scl-centos-6-4
https://serverfault.com/questions/751155/permanently-enable-a-scl
https://access.redhat.com/solutions/527703
IUS
IUS是一个社区维护的软件源,全名是Inline with Upstream Stable,官网为https://ius.io/,通过github组织社区https://github.com/iuscommunity
IUS被git帮助文档推荐作为centos等系统安装新版本git的第三方源:https://git-scm.com/download/linux
安装IUS是直接安装软件包,并不像SCL还带了虚拟环境的概念。所以使用起来相对简单,只是官方源速度国内可能并不十分友好,且缺少可用镜像。
安装git命令:
yum install epel-release
yum remove git
rpm -U https://centos7.iuscommunity.org/ius-release.rpm
yum install git2u
IUS为了避免与官方源冲突,所以对软件包名进行了修改, 规则为:{name}{major_version}{minor_version}u 。具体内容可参阅https://ius.io/Philosophy/
IUS支持的软件包,可通过github站点搜索查看 https://github.com/iuscommunity
通过上述两个源,大家在使用centos时,或许可以减少编译代码的工作量。
