本篇內(nèi)容介紹了“怎么安裝配置Yum”的有關(guān)知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細閱讀,能夠?qū)W有所成!
昆玉ssl適用于網(wǎng)站、小程序/APP、API接口等需要進行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為成都創(chuàng)新互聯(lián)的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18982081108(備注:SSL證書合作)期待與您的合作!
查看操作系統(tǒng)詳細信息:
lsb_release -a
查看操作系統(tǒng)發(fā)行信息:
cat /etc/*release
查看操作系統(tǒng)位數(shù):
getconf LONG_BIT
在 linux 系統(tǒng)上,軟件包之間的依賴關(guān)系是一件很讓人頭疼的事情。很多工作無法實現(xiàn)可能就是因為缺少一個軟件包,而當(dāng)你千方百計找到這個軟件包的時候,卻發(fā)現(xiàn)它跟當(dāng)前系統(tǒng)不兼容,這真是一件令人抓狂的事情。所以,我拿到蓋機器后,要做的非常重要的一件事情就是給系統(tǒng)添加軟件倉庫,以確保我能順利的安裝上大部分軟件包。
刪除系統(tǒng)自帶的 yum 服務(wù):
rpm -qa | grep yum | xargs rpm -e --nodeps
然后去鏡像網(wǎng)站下載 yum 的安裝包重新安裝。我選擇的是 163 的鏡像(http://mirrors.163.com/centos/),然后下載下列軟件包:
wget http://mirrors.163.com/centos/5/os/i386/CentOS/yum-3.2.22-40.el5.centos.noarch.rpm wget http://mirrors.163.com/centos/5/os/i386/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm wget http://mirrors.163.com/centos/5/os/i386/CentOS/yum-metadata-parser-1.1.2-4.el5.i386.rpm
下載完成后將它們?nèi)堪惭b上:
rpm -ivh *.rpm
安裝完 yum 后,我去 163 的官方網(wǎng)站(http://mirrors.163.com/.help/centos.html?1304848825)下載了一個配置文件放到 /etc/yum.repos.d 目錄下,然后運行以下命令,以清除緩存并下載新的鏡像緩存:
yum clean all yum makecache
問題出現(xiàn)了,運行 yum makecache 時提示鏡像地址不對。我手動打開該地址,發(fā)現(xiàn)該地址確實不存在。然后我將鏡像地址的目錄一級一級的向前退,終于發(fā)現(xiàn)了一個 readme 文件,該文件內(nèi)容如下:
wget This directory (and version of CentOS) is deprecated. For normal users, you should use /5/ and not /5.6/ 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.6 level, go to http://vault.centos.org/ for packages. Please keep in mind that 5.6 no longer gets any updates
原來是地址發(fā)生了變化,按照提示,在瀏覽器中找到了對應(yīng)的鏡像地址,于是修改配置文件:
gedit /etc/yum.repos.d/CentOS5-Base-163.repo
配置文件內(nèi)容如下:
# 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://mirrors.163.com/centos/5/os/i386/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/5/os/i386/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://mirrors.163.com/centos/5/updates/i386/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/5/os/i386/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://mirrors.163.com/centos/5/extras/i386/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/5/os/i386/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://mirrors.163.com/centos/5/centosplus/i386/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.163.com/centos/5/os/i386/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://mirrors.163.com/centos/5/contrib/i386/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.163.com/centos/5/os/i386/RPM-GPG-KEY-CentOS-5
保存后再次執(zhí)行以下命令:
yum clean all yum makecache
到此,添加軟件倉庫成功。
添加完 163 的軟件倉庫后,首先嘗試安裝了 git,發(fā)現(xiàn)倉庫里邊竟然沒有 git。不得不說 Redhat 系統(tǒng)是比較穩(wěn)定的,但是安裝一個軟件實在是太麻煩了,這也是我在個人電腦上不使用它的原因。沒辦法,添加第三方軟件倉庫試試吧。
yum-priorities 插件是用來設(shè)置yum在調(diào)用軟件源時的順序的。因為官方提供的軟件源,都是比較穩(wěn)定和被推薦使用的。因此,官方源的順序要高于第三方源的順序。如何保證這個順序,就需要安裝yum-priorities這插件了:
yum install yum-priorities
安裝完后需要設(shè)置/etc/yum.repos.d/ 目錄下的.repo相關(guān)文件(如CentOS-Base.repo),在這些文件中插入順序指令:priority=N (N為1到99的正整數(shù),數(shù)值越小越優(yōu)先),例如:
[epel] name=Extra Packages for Enterprise Linux 5 - $basearch #baseurl=http://download.fedoraproject.org/pub/epel/5/$basearch mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch failovermethod=priority enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL priority=2 [epel-debuginfo] name=Extra Packages for Enterprise Linux 5 - $basearch - Debug #baseurl=http://download.fedoraproject.org/pub/epel/5/$basearch/debug mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-debug-5&arch=$basearch failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL gpgcheck=1 priority=2 [epel-source] name=Extra Packages for Enterprise Linux 5 - $basearch - Source #baseurl=http://download.fedoraproject.org/pub/epel/5/SRPMS mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-source-5&arch=$basearch failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL gpgcheck=1 priority=2
epel 是 yum 的一個軟件源,里面包含了許多基本源里沒有的軟件,安裝 epel 源命令如下:
wget http://mirrors.yun-idc.com/epel/5/i386/epel-release-5-4.noarch.rpm rpm -ivh epel-release-5-4.noarch.rpm yum clean all yum makecache
再次嘗試安裝 git,成功了。
wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el5.rf.i386.rpm rpm -ivh rpmforge-release-0.5.3-1.el5.rf.i386.rpm yum clean all yum makecache
wget http://download1.rpmfusion.org/free/el/updates/5/i386/rpmfusion-free-release-5-1.noarch.rpm wget http://download1.rpmfusion.org/nonfree/el/updates/5/i386/rpmfusion-nonfree-release-5-1.noarch.rpm
下載完成之后同上安裝即可。安裝完后記得在配置文件中修改 priority=N,以修改軟件倉庫的加載順序。
在 Linux 下的工作大部分都是用命令來完成,而我總是懶得去那些繁復(fù)的命令,即使記憶再好,我想也記不住全部的命令。所以 Linux Shell 的 Tab 補全功能變得尤其重要。通常情況下, Shell 自帶的補全功能只能補全系統(tǒng)中簡單的命令。要增強 shell 的補全功能,需要安裝一個 bash-completion:
yum install -y bash-completion
安裝完成之后執(zhí)行以下命令:
echo '. /etc/bash_completion' >> /etc/bashrc source /etc/bashrc
這樣,在你輸入 yum install lib 之后,再按 Tab 鍵,便會列出所有的可安裝的軟件包。bash-completion 的補全功能是通過配置文件實現(xiàn)的,配置文件放在 /etc/bash_completion.d/ 下。如果發(fā)現(xiàn)有軟件工具無法自動補全,可以安裝相應(yīng)的配置文件試試。
“怎么安裝配置Yum”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實用文章!