centos7安装最新稳定版nginx

时间:2021-02-14 13:52:01

yum安装nginx官方文档地址

安装基础依赖

yum -y install gcc gcc-c++ autoconf pcre pcre-devel make automake
yum -y install wget httpd-tools vim
sudo yum install yum-utils

配置nginxyum

cd /etc/yum.repos.d
vim 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

查看nginx是否可以找到

yum list | grep nginx

centos7安装最新稳定版nginx

安装nginx

默认安装稳定版

yum -y install nginx

如果需要安装最新的nginx非稳定版可以执行如下设置

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

再执行yum安装

centos7安装最新稳定版nginx

nginx已经成功安装