Centos

Install the prerequisites:

  1. sudo yum install yum-utils

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. module_hotfixes=true
  8. [nginx-mainline]
  9. name=nginx mainline repo
  10. baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
  11. gpgcheck=1
  12. enabled=0
  13. gpgkey=https://nginx.org/keys/nginx_signing.key
  14. module_hotfixes=true

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

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

To install nginx, run the following command:

  1. sudo yum install nginx

When prompted to accept the GPG key, verify that the fingerprint matches573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62, and if so, accept it.

配置文件地址

  1. /etc/nginx/conf.d/nginx.conf