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
配置nginx
的yum
源
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
已经成功安装