III. introduction to Nginx configuration file

  • Configuration syntax of Nginx
  1. Configuration file consists of instruction and instruction block
  2. Each instruction ends with a; semicolon, and instructions and parameters are separated by a space symbol
  3. Instruction blocks organize multiple instructions together with {} braces
  4. include statement allows multiple profiles to be combined to improve maintainability
  5. Use the ා sign to add comments and improve readability
  6. Use $symbol to use variable
  7. Parameters of some instructions support normal expressions
  • Time unit of configuration parameter


  • Space units for configuration parameters


  • Nginx command line

1.nginx send signal

#Send reload signal to reload the configuration file (the same as kill-9)
[root@i-vvwtw5ne sbin]# ./nginx  -s reload 
#Stop service immediately by sending stop signal
[root@i-vvwtw5ne sbin]# ./nginx  -s stop 
#Send quit signal and stop service gracefully
[root@i-vvwtw5ne sbin]# ./nginx  -s quit 
#Send reopen signal to restart logging
[root@i-vvwtw5ne sbin]# ./nginx  -s reopen 

2. Get help from nginx

[root@i-vvwtw5ne sbin]# ./nginx  -h
nginx version: nginx/1.16.1
Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives]

  -?,-h         : this help
  -v            : show version and exit
  -V            : show version and configure options then exit
  -t            : test configuration and exit
  -T            : test configuration, dump it and exit
  -q            : suppress non-error messages during configuration testing
  -s signal     : send signal to a master process: stop, quit, reopen, reload
  -p prefix     : set prefix path (default: /opt/nginx/)
  -c filename   : set configuration file (default: conf/nginx.conf)
  -g directives : set global directives out of configuration file

3. By default, nginx uses the configuration file of $installPath/conf/nginx.conf. You can also use the specified configuration file, as follows

[root@i-vvwtw5ne sbin]# ./nginx  -c /opt/nginx/conf/mynginx.conf

4. Test the configuration file for syntax errors

[root@i-vvwtw5ne sbin]# ./nginx  -t

5. Print the version information of nignx

[root@i-vvwtw5ne sbin]# ./nginx -v

Tags: Programming Nginx Nignx

Posted on Sun, 03 Nov 2019 14:16:51 -0500 by MoMoMajor