Centos7安装SCL源
安装SCL源
SCL
是Software Collections
的缩写,由CentOS特别兴趣小组
所维护。其收录了许多程序的新版本
,例如gcc, PHP, git, python等。安装的软件可与旧版共存,包名多以rh-为前缀
。
参考: https://www.cnblogs.com/wswind/p/10729610.html
配置SCL https://chowdera.com/2021/10/20211015120730214l.html
SCL源软件搜索: https://www.softwarecollections.org
https://www.softwarecollections.org/en/scls/
# 安装SCL源---建议手动配置国内源
# yum install -y centos-release-scl centos-release-scl-rh
安装完成后在/etc/yum.repos.d
目录下会出现CentOS-SCLo-scl.repo
和CentOS-SCLo-scl-rh.repo
两个文件。安装后源默认启用。
配置scl国内源
参考: https://zhuanlan.zhihu.com/p/424953404
# 备份
cp CentOS-SCLo-scl.repo{,.bak}
cp CentOS-SCLo-scl-rh.repo{,.bak}
配置CentOS-SCLo-scl.repo
国内地址
vim /etc/yum.repos.d/CentOS-SCLo-scl.repo
[centos-sclo-sclo]
name=CentOS-7 - SCLo sclo
baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/sclo/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
配置CentOS-SCLo-scl-rh.repo
vim /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
[centos-sclo-rh]
name=CentOS-7 - SCLo rh
baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/rh/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
刷新缓存
# 刷新缓存
yum repolist && yum clean all && yum makecache
# 安装scl-utils工具
yum install -y scl-utils scl-utils-build
使用scl源安装新版的包
使用scl源安装git2
# 查找rh-git软件包
yum search rh-git2
# 安装新版的git
yum install -y rh-git227
# 激活新版的git
## 激活git的打开bash
scl enable rh-git227 bash
# 查看git版本
git --version
对特定用户生效scl版本
#通过bash环境来设定,仅对特定用户启用
vim ~/.bashrc
# or
~/.bash_profile
# 添加
source scl_source enable rh-git227
对全局用户启用scl版本
# 对全局用户启用scl版本
vim /etc/profile.d/enable_scl.sh
# 添加内容
source scl_source enable rh-git227
或者
# 全局启用scl版本
# 启用scl版本的git
scl enable rh-git227 bash
# 查看git所在位置
which git
## 回显
/opt/rh/rh-git227/root/usr/bin/git
# 将srl版本的git软链接到/usr/bin/git
ln -s /opt/rh/rh-git227/root/usr/bin/git /usr/bin/git
scl常用
从scl源中搜索软件
# 从scl源中搜索软件
yum --disablerepo="*" --enablerepo="centos-sclo-rh" search 包名
查看从 SCL 中安装的包
# 查看从 SCL 中安装的包
scl --list
获取当前会话中启用的软件集合的列表
# 获取当前会话中启用的软件集合的列表
echo $X_SCLS