解決CentOS安裝寶塔執(zhí)行yum命令錯誤:Error: Cannot find a valid baseurl for repo: base
今天在CentOS系統(tǒng)執(zhí)行yum命令時出現(xiàn)錯誤提示: Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
YumRepo Error: All mirror URLs are not using ftp, http(s) or file.
Eg. Invalid release/repo/arch combination/
removing mirrorlist with no valid mirrors: /var/cache/yum/x86_64/6/base/mirrorlist.txt
Error: Cannot find a valid baseurl for repo: base
錯誤信息大概意思是緩存的鏡像文件里的URL無效了,,所以無法下載程序文件來安裝,。
202104020724141855.gif (21.18 KB)
下載附件
2021-7-22 15:56 上傳
Cannot find a valid baseurl for repo base 百度答案不少,,但都不能解決問題,,最后還是在谷歌找到了解決方法,,其實也很簡單,,只需依次執(zhí)行如下三行代碼:
- echo "http://vault.centos.org/6.7/os/x86_64/" > /var/cache/yum/x86_64/6/base/mirrorlist.txt
- echo "http://vault.centos.org/6.7/extras/x86_64/" > /var/cache/yum/x86_64/6/extras/mirrorlist.txt
- echo "http://vault.centos.org/6.7/updates/x86_64/" > /var/cache/yum/x86_64/6/updates/mirrorlist.txt
注意: 1,、Centos系統(tǒng)版本號 代碼中 5.11 是CentOS版本號,,要改為你服務(wù)器安裝的CentOS的版本號,CentOS系統(tǒng)的版本號用此命令查看:
202104020655401523.gif (1.1 KB)
下載附件
2021-7-22 15:56 上傳
該CentOS系統(tǒng)版本號是7.4.1708,,所以要把代碼里的 5.11 改為 7.4.1708,。
2、mirrorlist.txt路徑 代碼中的 mirrorlist.txt 路徑要改為錯誤提示中給出的路徑,,比如看到下面的提示: removing mirrorlist with no valid mirrors: /var/cache/yum/x86_64/6/base/mirrorlist.txt
mirrorlist.txt 路徑便是: /var/cache/yum/x86_64/6/base/mirrorlist.txt
知道這個后,,我們依次執(zhí)行前面提到的三行代碼時,把路徑的base改為extras和updates來執(zhí)行(記得先按第1步更改版本號),。
|