使用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