一、在centos下使用yum install -y nginx 命令時(shí),出現(xiàn)如下錯(cuò)誤:
[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
沒(méi)有可用軟件包 nginx。
錯(cuò)誤:無(wú)須任何處理
二、問(wèn)題原因
nginx位于第三方的yum源里面,而不在centos官方yum源里面
三、解決方法
查看系統(tǒng)是6還是7
[root@hadoop100 /]# cat /etc/redhat-release
在使用yum install命令時(shí),可以直接指定安裝包的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
另外說(shuō)明,如果在RHEL上安裝,還需要安裝與啟動(dòng)EPEL相關(guān)的組件;
# subscription-manager repos –enable “rhel-*-optional-rpms” –enable “rhel-*-extras-rpms”
執(zhí)行下面的命令
[root@hadoop100 /] yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
再次執(zhí)行安裝命令即可
方案二:直接下載一個(gè)epel源替代系統(tǒng)的軟件源:
配置yum源、epel源為國(guó)內(nèi)鏡像
cd /etc/yum.repos.d
獲取阿里centos7的base-repo