Centos7下yum安装nginx

Centos7下启动nginx:

  1. systemctl start nginx
  2. systemctl stop nginx
  3. systemctl restart nginx

Install the prerequisites:

  1. yum install yum-utils -y

To set up the yum repository, create the file named /etc/yum.repos.d/nginx.repo with the following contents:

  1. [nginx-stable]
  2. name=nginx stable repo
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
  4. gpgcheck=1
  5. enabled=1
  6. gpgkey=https://nginx.org/keys/nginx_signing.key
  7. [nginx-mainline]
  8. name=nginx mainline repo
  9. baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
  10. gpgcheck=1
  11. enabled=0
  12. gpgkey=https://nginx.org/keys/nginx_signing.key

By default, the repository for stable nginx packages is used. If you would like to use mainline nginx packages, run the following command:

  1. yum-config-manager —enable nginx-mainline

To install nginx, run the following command:

  1. yum -y install nginx

注意配置nginx.conf 将 user=root