Hptyer-v虚拟机 yum install nginx -y安装时出错解决办法

注:本文使用的是Hptyer-v创建的虚拟机,有些配置未设置。如使用阿里、腾讯、华为云可忽略此步骤。
本机安装nginx时出错:

[root@localhost ~]# yum install nginx -y
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.huaweicloud.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.huaweicloud.com
 * 没有可用软件包 nginx。
  1. 问题原因:
    nginx位于第三方的yum源里面,而不在centos官方yum源里面

  2. 解决方法:
    2.1 查看系统版本

[root@localhost yum.repos.d]# cat /etc/redhat-release 
CentOS Linux release 7.9.2009 (Core)

2.2 那么在使用yum install命令时,可以直接指定安装包的https下载路径,如下:
CentOS 7版本下载安装:

yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

再次执行:yum install nginx -y 即可安装

方案二:直接下载一个epel源替代系统的软件源:
配置yum源、epel源为国内镜像
cd /etc/yum.repos.d

获取阿里centos7的base-repo
wget https://mirrors.aliyun.com/repo/epel-7.repo
会把文件下载下来,直接yum install nginx -y即可

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值