1. /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

2. 安装

yum -y install nginx


# 查看版本
nginx -v

3. 常用命令


# 允许开机启动
systemctl enable nginx
# 启动
systemctl start nginx
# 停止
systemctl stop nginx
# 重新加载配置文件
systemctl reload nginx
# 看状态
systemctl status nginx