CentOS 使用 IUS / SCL 第三方软件源

使用centos 经常发现官方提供的软件包版本过低,很多时候大家会选择下载源码自行编译,带来了很多麻烦。
centos安装最新版本软件包,例如git,python等,可以通过红帽官方提供的software collection,或者社区提供的ius实现。

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
rpm -U https://centos7.iuscommunity.org/ius-release.rpm
yum remove git
yum install git2u

IUS为了避免与官方源冲突,所以对软件包名进行了修改, 规则为:{name}{major_version}{minor_version}u 。
IUS支持的软件包,可通过github查询

IUS直接访问速度不是很理想,可以设置国内镜像:

IUS 站点根目录为:https://dl.iuscommunity.org/pub/ius/
对应的阿里云镜像为:https://mirrors.aliyun.com/ius/
镜像列表:https://mirrors.iuscommunity.org/mirrors
清华大学镜像:https://mirrors.tuna.tsinghua.edu.cn/ius/
同济大学镜像:https://mirrors.tongji.edu.cn/ius/

编辑 /etc/yum.repos.d/ius.repo,将官方网址修改为镜像地址

命令替换:

sed -i "s|repo.ius.io|mirrors.tuna.tsinghua.edu.cn/ius|g" /etc/yum.repos.d/ius.repo

repo文件:

[ius]
name = IUS for Enterprise Linux 7 - $basearch
baseurl = https://mirrors.tuna.tsinghua.edu.cn/ius/7/$basearch/
enabled = 1
repo_gpgcheck = 0
gpgcheck = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-IUS-7

[ius-debuginfo]
name = IUS for Enterprise Linux 7 - $basearch - Debug
baseurl = https://mirrors.tuna.tsinghua.edu.cn/ius/7/$basearch/debug/
enabled = 0
repo_gpgcheck = 0
gpgcheck = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-IUS-7

[ius-source]
name = IUS for Enterprise Linux 7 - Source
baseurl = https://mirrors.tuna.tsinghua.edu.cn/ius/7/src/
enabled = 0
repo_gpgcheck = 0
gpgcheck = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-IUS-7

update:

通过镜像安装

wget https://mirrors.aliyun.com/ius/ius-release-el7.rpm
rpm -i ius-release-el7.rpm

参考:
https://www.cnblogs.com/f-ck-need-u/p/8494992.html

SCL

scl不是一个简单的包管理工具,而是类似python的venv(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

或者

scl enable rh-git29 bash
which git
/opt/rh/rh-git29/root/usr/bin/git

ln -s /opt/rh/rh-git29/root/usr/bin/git  /usr/bin/git 

其他软件源:

https://www.cnblogs.com/mawanglin2008/p/3532247.html

参考:

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

原文地址:https://www.cnblogs.com/wswind/p/10729610.html