安装nginx时报错:No package nginx available. Error: Nothing to do

来源:互联网 发布:网上配眼镜 知乎 编辑:程序博客网 时间:2024/05/22 10:36

在安装nginx时出现以下错误:

[root@localhost data]# yum install nginx -y

Loaded plugins: fastestmirror, security

Loading mirror speeds from cached hostfile

 *base: mirrors.163.com

 *extras: mirrors.163.com

 *updates: centos.ustc.edu.cn

Setting up Install Process

No package nginx available.

Error: Nothing to do

解决方案:

出现这个的原因是因为本地yum源中没有我们想要的nginx,那么我们就需要创建一个“/etc/yum.repos.d/nginx.repo”的文件,新增一个yum源。

[root@localhost data]# vim /etc/yum.repos.d/nginx.repo

在这个文件中写入以下内容:

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1

退出保存后,我们可以使用yum命令来查询nginx的yum源配置好了没有。

[root@localhost data]# yum list | grep nginx

如果显示以下效果:

nginx.x86_641:1.10.1-1.el7.ngx nginx
nginx-debug.x86_64 1:1.8.0-1.el7.ngx nginx
nginx-debuginfo.x86_64 1:1.10.1-1.el7.ngx nginx
nginx-module-geoip.x86_64 1:1.10.1-1.el7.ngx nginx
nginx-module-image-filter.x86_64 1:1.10.1-1.el7.ngx nginx
nginx-module-njs.x86_64 1:1.10.1.0.0.20160414.1c50334fbea6-1.el7.ngx
nginx
nginx-module-perl.x86_64 1:1.10.1-1.el7.ngx nginx
nginx-module-xslt.x86_64 1:1.10.1-1.el7.ngx nginx
nginx-nr-agent.noarch 2.0.0-9.el7.ngx nginx
pcp-pmda-nginx.x86_64 3.10.6-2.el7 base

则我们nginx的yum源就配置成功啦!

最后就可以直接安装:

[root@localhost data]# yum -y install nginx

大功告成!
阅读全文
0 0
原创粉丝点击