CentOS 5.x yum Error Cannot find a vaild baseurl


因為CentOS 5.x版本較舊,直接用yum可能會出現
Error: Cannot find a valid baseurl for repo: base的問題,
所以安裝前,請先找到/etc/yum.repos.d/Centos-Base.repo的檔案,修改前先備份一份
cd /etc/yum.repo.d/
cp Centos-Base.repo Centos-Base.repo.Bak
然後使用vim開啟Centos-Base.repo檔案,刪除原本內容
vim Centos-Base.repo
按下Ctrl + G 跳至最後一行,輸入:1,.d (從第1行刪除至最後一行)
複製以下內容貼上,:wq儲存後再次執行yum就能正常執行。
# 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-5.9 - Base

#mirrorlist=http://mirrorlist.centos.org/?release=5.9&arch=$basearch&repo=os

baseurl=http://vault.centos.org/5.9/os/$basearch/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5



#released updates

[updates]

name=CentOS-5.9 - Updates

#mirrorlist=http://mirrorlist.centos.org/?release=5.9&arch=$basearch&repo=updates

baseurl=http://vault.centos.org/5.9/updates/$basearch/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5



#additional packages that may be useful

[extras]

name=CentOS-5.9 - Extras

#mirrorlist=http://mirrorlist.centos.org/?release=5.9&arch=$basearch&repo=extras

baseurl=http://vault.centos.org/5.9/extras/$basearch/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5



#additional packages that extend functionality of existing packages

[centosplus]

name=CentOS-5.9 - Plus

#mirrorlist=http://mirrorlist.centos.org/?release=5.9&arch=$basearch&repo=centosplus

baseurl=http://vault.centos.org/5.9/os/$basearch/centosplus/

gpgcheck=1

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5



#contrib - packages by Centos Users

[contrib]

name=CentOS-5.9 - Contrib

#mirrorlist=http://mirrorlist.centos.org/?release=5.9&arch=$basearch&repo=contrib

baseurl=http://vault.centos.org/5.9/os/$basearch/contrib/

gpgcheck=1

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
參考資料
Stackoverflow
https://stackoverflow.com/questions/43766169/error-cannot-find-a-valid-baseurl-for-repo-base



留言