一、Nginx配置文件详解

image-20201227153205167.png

配置文件结构

主要分为四个部分

  1. main(全局设置):main部分设置的指令将影响到其他所有部分的设置
  2. server(主机设置):server部分的指令主要用于指定虚拟主机的域名、IP和端口
  3. upstream(上游服务器设置):主要为反向代理、负载均衡先关配置
  4. location(URL匹配设置):location部分用于匹配网页位置

二、常用命令

命令 中文解释
帮助 nginx -h
启动Nginx服务器 sudo nginx
指定配置文件的方式启动 sudo nginx -c /usr/local/nginx/conf/mynginx/conf
暴力停止服务器 sudo nginx -s stop
优雅停止服务器 sudo nginx -s quit
重新加载配置文件 sudo nginx -s reload