Cannot find a valid baseurl for repo: base/7/x86_64

小鲨鱼2018發表於2024-12-03

001、yum報錯

(base) [root@PC1 yum.repos.d]# yum install httpd       ## yum安裝應用報錯

002、解決方法

(base) [root@PC1 home]# cd /etc/yum.repos.d
(base) [root@PC1 yum.repos.d]# ls
CentOS-Base.repo  CentOS-CR.repo  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  CentOS-Media.repo  CentOS-Sources.repo  CentOS-Vault.repo
(base) [root@PC1 yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo_bak
(base) [root@PC1 yum.repos.d]# vim CentOS-Base.repo
(base) [root@PC1 yum.repos.d]# vim CentOS-Base.repo       ## 增加一下內容到改檔案中,儲存退出
(base) [root@PC1 yum.repos.d]#
[base]
name=CentOS-$releasever - Base
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

003、測試效果

(base) [root@PC1 yum.repos.d]# yum install httpd -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
base                                                                                                                                   | 3.6 kB  00:00:00
extras                                                                                                                                 | 2.9 kB  00:00:00
updates                                                                                                                                | 2.9 kB  00:00:00
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-99.el7.centos.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================
 Package                          Arch                              Version                                          Repository                          Size
==============================================================================================================================================================
Installing:
 httpd                            x86_64                            2.4.6-99.el7.centos.1                            updates                            2.7 M

Transaction Summary
==============================================================================================================================================================
Install  1 Package

Total download size: 2.7 M
Installed size: 9.4 M
Downloading packages:
httpd-2.4.6-99.el7.centos.1.x86_64.rpm                                                                                                 | 2.7 MB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : httpd-2.4.6-99.el7.centos.1.x86_64                                                                                                         1/1
  Verifying  : httpd-2.4.6-99.el7.centos.1.x86_64                                                                                                         1/1

Installed:
  httpd.x86_64 0:2.4.6-99.el7.centos.1

Complete!

ref:

01、https://www.cnblogs.com/lhboke/p/18411189

相關文章