在公司接手一台伺服器,準備做點想做的事,發現竟然連vim都沒有,沒事,我自己裝,悲劇的發現連Yum都沒裝…..
伺服器的的環境是Red Hat Enterprise Linux AS release 4 (Nahant Update 8),這都早八百年的老系統了,伺服器的配置還行。好了,我們開始幹正事,我的目標是:
- 1. 安裝Yum,配置好CentOS的源,選了網易163的源
- 2. 順便用Yum安裝一個Vim來玩
首先從這篇文章Red Hat 安裝Yum,按照下面的步驟來安裝Yum
先下載Yum的rpm包
cd /syr/local/
wget -c http://yum.baseurl.org/download/2.0/yum-2.0.8-1.src.rpm
使用rpm方式安裝
rpmbuild --rebuild yum-2.0.8-1.src.rpm
cd /usr/src/redhat/RPMS/noarch/
rpm -ivh yum-2.0.8-1.noarch.rpm
運行yum會出現報錯
retrygrab() failed for: http://mirror.dulug.duke.edu/pub/yum-repository/redhat/4AS/i386/headers/header.info
Executing failover method
failover: out of servers to try
Error getting file http://mirror.dulug.duke.edu/pub/yum-repository/redhat/4AS/i386/headers/header.info
[Errno 4] IOError:
Red Hat預設的源太老了,都沒辦法更新了,得更換為163的源.
修改yum.conf設定檔
vi /etc/yum.conf
詳細配置如下
[main]
cachedir=/var/cache/yumdebuglevel=2
logfile=/var/log/yum.log
pkgpolicy=newest
installonlypkgs=kernel kernel-smp kernel-devel kernel-smp-devel kernel-largesmp kernel-largesmp-devel kernel-hugemem kernel-hugemem-devel
distroverpkg=centos-release
tolerant=1
exactarch=1
retries=20
obsoletes=1
gpgcheck=1
plugins=1
# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
根據163的說明,配置好/etc/yum.repos.d/CentOS-Base.repo檔案,就可以開始安裝Vim了。
先找到Vim的安裝包
yum list | grep vim
會列出與vim相關的包
vim-minimal.i386 1:6.3.046-2.el4.1 installed
vim-X11.i386 1:6.3.046-2.el4.1 base
vim-common.i386 1:6.3.046-2.el4.1 base
vim-enhanced.i386 1:6.3.046-2.el4.1 base
安裝vim-enhanced.i386這個包就可以了
yum install vim-enhanced.i386
會提示你是否匯入GPG key,輸入y即可
warning: rpmts_HdrFromFdno: V3 DSA signature: NOKEY, key ID 443e1821
Public key for vim-enhanced-6.3.046-2.el4.1.i386.rpm is not installed
Retrieving GPG key from http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
Importing GPG key 0x443E1821 "CentOS-4 key "
Is this ok [y/N]: y
最後終於安裝成功了,Vim我愛死你了。
Key imported successfully
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: vim-common ######################### [1/2]
Installing: vim-enhanced ######################### [2/2]
Installed: vim-enhanced.i386 1:6.3.046-2.el4.1
Dependency Installed: vim-common.i386 1:6.3.046-2.el4.1
Complete!
Done!
摘自:http://www.xbc.me/install-yum-on-red-hat/