yum install httpd -y



Last login: Tue May  8 12:41:42 2018 from 192.168.72.1
[wangshumin@CentOSNode1 ~]$ yum install httpd -y
已加载插件:fastestmirror, langpacks, product-id, search-disabled-repos, subscription-manager
您需要 root 权限执行此命令。
[wangshumin@CentOSNode1 ~]$ sudo yum install httpd -y
[sudo] wangshumin 的密码:
已加载插件:fastestmirror, langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
base                                                                                                                                                                  | 3.6 kB  00:00:02     
extras                                                                                                                                                                | 3.4 kB  00:00:00     
updates                                                                                                                                                               | 3.4 kB  00:00:00     
Determining fastest mirrors
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 httpd.x86_64.0.2.4.6-67.el7.centos.6 将被 安装
--> 正在处理依赖关系 httpd-tools = 2.4.6-67.el7.centos.6,它被软件包 httpd-2.4.6-67.el7.centos.6.x86_64 需要
--> 正在处理依赖关系 /etc/mime.types,它被软件包 httpd-2.4.6-67.el7.centos.6.x86_64 需要
--> 正在检查事务
---> 软件包 httpd-tools.x86_64.0.2.4.6-67.el7.centos.6 将被 安装
---> 软件包 mailcap.noarch.0.2.1.41-2.el7 将被 安装
--> 解决依赖关系完成


依赖关系解决


=============================================================================================================================================================================================
 Package                                      架构                                    版本                                                    源                                        大小
=============================================================================================================================================================================================
正在安装:
 httpd                                        x86_64                                  2.4.6-67.el7.centos.6                                   updates                                  2.7 M
为依赖而安装:
 httpd-tools                                  x86_64                                  2.4.6-67.el7.centos.6                                   updates                                   88 k
 mailcap                                      noarch                                  2.1.41-2.el7                                            base                                      31 k


事务概要
=============================================================================================================================================================================================
安装  1 软件包 (+2 依赖软件包)


总下载量:2.8 M
安装大小:9.6 M
Downloading packages:
(1/3): mailcap-2.1.41-2.el7.noarch.rpm                                                                                                                                |  31 kB  00:00:02     
(2/3): httpd-tools-2.4.6-67.el7.centos.6.x86_64.rpm                                                                                                                   |  88 kB  00:00:20     
(3/3): httpd-2.4.6-67.el7.centos.6.x86_64.rpm                                                                                                                         | 2.7 MB  00:01:30     
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                                                          29 kB/s | 2.8 MB  00:01:40     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : httpd-tools-2.4.6-67.el7.centos.6.x86_64                                                                                                                                 1/3 
  正在安装    : mailcap-2.1.41-2.el7.noarch                                                                                                                                              2/3 
  正在安装    : httpd-2.4.6-67.el7.centos.6.x86_64                                                                                                                                       3/3 
  验证中      : mailcap-2.1.41-2.el7.noarch                                                                                                                                              1/3 
  验证中      : httpd-2.4.6-67.el7.centos.6.x86_64                                                                                                                                       2/3 
  验证中      : httpd-tools-2.4.6-67.el7.centos.6.x86_64                                                                                                                                 3/3 


已安装:
  httpd.x86_64 0:2.4.6-67.el7.centos.6                                                                                                                                                       


作为依赖被安装:
  httpd-tools.x86_64 0:2.4.6-67.el7.centos.6                                                          mailcap.noarch 0:2.1.41-2.el7                                                         


完毕!
[wangshumin@CentOSNode1 ~]$ sudo vim /var/www/html/index.html
[wangshumin@CentOSNode1 ~]$  systemctl restart httpd
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: root
Password: 
==== AUTHENTICATION COMPLETE ===
[wangshumin@CentOSNode1 ~]$  sudo netstat -ntlp 
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1/systemd           
tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      1385/dnsmasq        
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      914/sshd            
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      913/cupsd           
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1221/master         
tcp        0      0 192.168.72.141:1883     0.0.0.0:*               LISTEN      1977/mosquitto      
tcp6       0      0 :::111                  :::*                    LISTEN      1/systemd           
tcp6       0      0 :::80                   :::*                    LISTEN      9277/httpd          
tcp6       0      0 :::22                   :::*                    LISTEN      914/sshd            
tcp6       0      0 ::1:631                 :::*                    LISTEN      913/cupsd           
tcp6       0      0 ::1:25                  :::*                    LISTEN      1221/master         
[wangshumin@CentOSNode1 ~]$ 
[root@localhost ~]# yun install httpd -y bash: yun: 未找到命令... [root@localhost ~]# yum install httpd -y 已加载插件fastestmirror, langpacks Loading mirror speeds from cached hostfile Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误" One of the configured repositories failed (未知), and yum doesn't have enough cached data to continue. At this point the only safe thing yum can do is fail. There are a few ways to work "fix" this: 1. Contact the upstream for the repository and get them to fix the problem. 2. Reconfigure the baseurl/etc. for the repository, to point to a working upstream. This is most often useful if you are using a newer distribution release than is supported by the repository (and the packages for the previous distribution release still work). 3. Run the command with the repository temporarily disabled yum --disablerepo=<repoid> ... 4. Disable the repository permanently, so yum won't use it by default. Yum will then just ignore the repository until you permanently enable it again or use --enablerepo for temporary usage: yum-config-manager --disable <repoid> or subscription-manager repos --disable=<repoid> 5. Configure the failing repository to be skipped, if it is unavailable. Note that yum will try to contact the repo. when it runs most commands, so will have to try and fail each time (and thus. yum will be be much slower). If it is a very temporary problem though, this is often a nice compromise: yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true Cannot find a valid baseurl for repo: base/7/x86_64什么原因怎么解决
03-08
<think>好的,用户遇到了在CentOS 7上安装Apache时出现的“Cannot find a valid baseurl for repo: base/7/x86_64”错误。之前已经给过他们一个详细的解决方案,现在他们再次提问,可能之前的步骤没有完全解决问题,或者他们在执行过程中遇到了新的困难。需要仔细分析他们提供的错误信息,找出可能的原因,并给出更明确的解决步骤。 首先,用户输入了错误的命令“yun install httpd -y”,系统提示命令未找到,这说明用户可能存在拼写错误,后来他们纠正为“yum install httpd -y”,但遇到了镜像列表无法解析的问题。错误信息显示curl无法解析mirrorlist.centos.org,这通常与DNS配置或网络连接有关。可能的问题点包括DNS服务器设置不正确、网络不可达、或者CentOS官方仓库已经停止维护导致镜像地址失效。 根据之前的回答,用户可能已经尝试过切换镜像源到vault.centos.org,但可能没有正确执行sed命令,或者需要进一步验证步骤是否正确。此外,用户可能没有正确禁用mirrorlist而启用baseurl,导致仍然尝试访问旧的镜像列表。也有可能系统时间不同步,导致SSL证书验证失败,但错误信息中未直接提及时间问题,所以这可能不是主要原因。 接下来需要分步骤引导用户检查网络连接,确保DNS配置正确,然后切换到可用的仓库镜像,如阿里云或vault.centos.org,并确保仓库配置文件中的设置正确。此外,可能需要手动替换repo文件,或者使用备份的镜像源。最后,清理yum缓存并重新生成,再尝试安装Apache。 需要考虑到用户可能对Linux命令不够熟悉,因此步骤需要详细且明确,避免使用复杂术语,同时提供验证命令,让用户能够逐步检查每个环节是否成功。例如,检查ping和curl命令的结果,确保网络和DNS正常工作;编辑repo文件时,提供具体的sed命令或手动修改的步骤;替换为阿里云的repo文件时,给出curl命令的具体示例。此外,提醒用户注意备份原有配置文件,以防万一。 另外,用户可能使用的是较旧的CentOS 7系统,而官方仓库已经停止维护,因此必须切换到归档镜像或第三方镜像源。需要明确告知用户这一情况,并提供相应的解决方案。同时,如果所有方法都无效,可能需要建议升级系统或迁移到其他维护中的发行版,如AlmaLinux或Rocky Linux。 最后,总结解决步骤,按优先级排列,确保用户能够一步步排查和解决问题,并在最后提供验证安装的命令,确保Apache正确安装并运行。</think>这是典型的CentOS 7仓库连接失败问题,由官方仓库停止维护引发。按以下步骤解决: --- ### 🌐 优先处理DNS解析(关键步骤) ```bash # 临时设置Google DNS sudo echo "nameserver 8.8.8.8" >> /etc/resolv.conf # 永久配置DNS(推荐) sudo tee /etc/sysconfig/network-scripts/ifcfg-* << EOF DNS1=8.8.8.8 DNS2=114.114.114.114 EOF # 验证解析能力 ping -c 3 mirrorlist.centos.org # 应返回IP地址 ``` --- ### 🔄 切换镜像源(必选方案) ```bash # 备份原仓库文件 sudo mkdir /etc/yum.repos.d/backup sudo mv /etc/yum.repos.d/CentOS-*.repo /etc/yum.repos.d/backup/ # 使用阿里云镜像源(适配CentOS 7) sudo curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo # 或使用官方归档源(二选一) sudo sed -i 's/mirror\.centos\.org/vault.centos.org/g' /etc/yum.repos.d/CentOS-* sudo sed -i 's/^mirrorlist=/#mirrorlist=/g' /etc/yum.repos.d/CentOS-* # 禁用镜像列表 sudo sed -i 's/^#baseurl=/baseurl=/g' /etc/yum.repos.d/CentOS-* # 启用基础URL ``` --- ### ⚡ 执行清理与重建 ```bash # 强制清理缓存 sudo rm -rf /var/cache/yum sudo yum clean all # 生成新缓存 sudo yum makecache ``` --- ### 📦 安装验证 ```bash # 测试安装httpd sudo yum install -y httpd # 启动服务验证 sudo systemctl start httpd curl -I 127.0.0.1 # 应返回HTTP 403(服务正常但无页面) ``` --- ### 📍 特殊场景处理 **若仍出现错误**,手动指定镜像URL: ```bash sudo tee /etc/yum.repos.d/CentOS-Base.repo << 'EOF' [base] name=CentOS-7 - Base baseurl=https://vault.centos.org/7.9.2009/os/x86_64/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 EOF ``` --- ### ⚠️ 终极建议 如果上述操作无效,说明系统环境已严重损坏,建议: 1. 下载[CentOS 7.9 ISO](https://vault.centos.org/7.9.2009/isos/x86_64/)重装系统 2. 迁移至[AlmaLinux](https://almalinux.org/)或[Rocky Linux](https://rockylinux.org/) > 💡 扩展提示:可通过`yum repoinfo base`验证仓库元数据获取状态,正常应显示仓库包数量及更新时间。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值