官网安装文档
http://nginx.org/en/linux_packages.html#RHEL-CentOS
nginx源
vim /etc/yum.repos.d/nginx.repo
stable 稳定版本
mainline 主线版本
[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
安装
sudo yum install nginx
常用命令
# 启动
sudo systemctl start nginx.service
# 关闭
sudo systemctl stop nginx.service
# 开机自启
sudo systemctl enable nginx.service