配置仓库

建立 /etc/yum.repos.d/nginx.repo 并粘贴如下内容

  1. [nginx]
  2. name=nginx repo
  3. baseurl=http://nginx.org/packages/centos/7/$basearch/
  4. gpgcheck=0
  5. enabled=1

安装

  1. yum install nginx -y
  2. systemctl enable nginx

启动

  1. #启动
  2. systemctl start nginx
  3. #停止
  4. systemctl stop nginx
  5. #重载
  6. systemctl reload nginx