一、在centos下使用yum install -y nginx 命令時,出現如下錯誤:
[root@hadoop100 /]#yum install -y nginx
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.huaweicloud.com
* extras: mirrors.huaweicloud.com
* updates: mirrors.huaweicloud.com
沒有可用軟件包 nginx。
錯誤:無須任何處理
二、問題原因
nginx位于第三方的yum源里面,而不在centos官方yum源里面
三、解決方法
查看系統是6還是7
[root@hadoop100 /]# cat /etc/redhat-release
在使用yum install命令時,可以直接指定安裝包的https下載路徑,如下:
RHEL/centos 6:
# yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
RHEL/centos 7:
# yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
另外說明,如果在RHEL上安裝,還需要安裝與啟動EPEL相關的組件;
# subscription-manager repos –enable “rhel-*-optional-rpms” –enable “rhel-*-extras-rpms”
執行下面的命令
[root@hadoop100 /] yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
再次執行安裝命令即可
方案二:直接下載一個epel源替代系統的軟件源:
配置yum源、epel源為國內鏡像
cd /etc/yum.repos.d
獲取阿里centos7的base-repo