centos7安装最新稳定版nginx

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

安装nginx

默认安装稳定版

yum -y install nginx

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

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

再执行yum安装

nginx已经成功安装

posted @ 2019-08-23 09:50  if年少有为  阅读(695)  评论(1编辑  收藏  举报