欢迎来到starnight_cyber的博客

RHEL/CentOS 安装最新版Nginx

  本篇简单介绍如何在RHEL/CentOS安装最新版本的Nginx。

  Step 1:安装yum-utils

[root@localhost ~]# cat /etc/redhat-release 
CentOS Linux release 7.6.1810 (Core) 
[root@localhost ~]# yum install yum-utils -y

  Step 2:

  创建一个名为/etc/yum.repos.d/nginx.repo的配置文件,内容如下:

[root@localhost ~]# vim /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

  Step 3:(根据所需,可跳过)

  默认情况下,使用稳定nginx包的存储库。如果要使用主线nginx包,请运行以下命令:

# sudo yum-config-manager --enable nginx-mainline

  Step 4:安装nignx

# sudo yum install nginx -y

  Step 5:查看版本

[root@localhost ~]# nginx -v        # 稳定包版本
nginx version: nginx/1.16.1

[root@localhost ~]# nginx -v        # 主线nginx
nginx version: nginx/1.17.5

  参考:

    http://nginx.org/en/linux_packages.html#RHEL-CentOS

posted @ 2019-11-18 09:14  starnight_cyber  阅读(983)  评论(0编辑  收藏  举报