CentOS配置Nginx官方的Yum源

这几天做博客发现CentOS 中没有自己用的nginx 所以就无法直接安装 nginx 了由于 yum 源中没有我们想要的 nginx,那么我们就需要创建一个

“/etc/yum.repos.d/nginx.repo”的文件,其实就是新增一个 yum 源。

[root@node~]# vim /etc/yum.repos.d/nginx.repo

然后将下面的内容复制进去:

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/Centos/7/$basearch/
gpgcheck=0
enabled=1
然后保存“/etc/yum.repos.d/nginx.repo”文件后,我们就使用 yum 命令查询一下我们的 nginx 的 yum 源配置好了没有。

[root@node1 yum.repos.d]# yum list|grep nginx
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
nginx.x86_64                                1:1.14.0-1.el7_4.ngx       nginx    
nginx-debug.x86_64                          1:1.8.0-1.el7.ngx          nginx    
nginx-debuginfo.x86_64                      1:1.14.0-1.el7_4.ngx       nginx    
nginx-module-geoip.x86_64                   1:1.14.0-1.el7_4.ngx       nginx    
nginx-module-geoip-debuginfo.x86_64         1:1.14.0-1.el7_4.ngx       nginx    
nginx-module-image-filter.x86_64            1:1.14.0-1.el7_4.ngx       nginx    
nginx-module-image-filter-debuginfo.x86_64  1:1.14.0-1.el7_4.ngx       nginx    
nginx-module-njs.x86_64                     1:1.14.0.0.2.4-1.el7_4.ngx nginx    
nginx-module-njs-debuginfo.x86_64           1:1.14.0.0.2.4-1.el7_4.ngx nginx    
nginx-module-perl.x86_64                    1:1.14.0-1.el7_4.ngx       nginx    
nginx-module-perl-debuginfo.x86_64          1:1.14.0-1.el7_4.ngx       nginx    
nginx-module-xslt.x86_64                    1:1.14.0-1.el7_4.ngx       nginx    
nginx-module-xslt-debuginfo.x86_64          1:1.14.0-1.el7_4.ngx       nginx    
nginx-nr-agent.noarch                       2.0.0-12.el7.ngx           nginx    
pcp-pmda-nginx.x86_64                       3.12.2-5.el7               base

如果执行命令是这样的显示效果,那么我们的 nginx 的 yum 源就配置成功啦!

然后要安装我们的 nginx 就直接执行:yum -y install nginx

如果操作正确到这里 nginx 环境就已经安装 OK 了

还可以使用命令查一下究竟是否安装完成。

[root@node1 yum.repos.d]# rpm -q nginx
nginx-1.14.0-1.el7_4.ngx.x86_64

已经成功了,并且是 nginx 官方的最新版本。

posted @ 2018-10-10 21:17  palyer  阅读(4461)  评论(0编辑  收藏  举报