nginx command line parameters

Tags (space separated): nginx

1 nginx common commands


[root@localhost nginx]# nginx -h
nginx version: nginx/1.10.2
Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives]

Options:
  -?,-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: /usr/local/nginx/)
  -c filename   : set configuration file (default: /usr/local/nginx/conf/nginx.conf)
  -g directives : set global directives out of configuration file

Nginx has only a few command line parameters, which are completely configured through configuration files.

-c specifies a configuration file for Nginx instead of the default one.

-t Do not run, but only test the configuration file. nginx will check the syntax of the configuration file for correctness and try to open the files referenced in the configuration file.

-v displays nginx version.

-V displays nginx version, compiler version and configuration parameters.

2 Start nginx

[root@localhost ~]# nginx

3 Stop nginx

[root@localhost ~]# nginx -s stop
# or
[root@localhost ~]# nginx -s quit

4 Reload nginx configuration

[root@localhost ~]# nginx -s reload
# or
[root@localhost ~]# nginx -s quit

5 Specify the configuration file

[root@localhost ~]# nginx -c /usr/local/nginx/conf/nginx.conf

6 Check whether the configuration file is correct

[root@localhost ~]# nginx -t

7 Help information

[root@localhost ~]# nginx -h
[root@localhost ~]# #or
[root@localhost ~]# nginx -?

8 Check Nginx version

[root@localhost ~]# nginx -v
[root@localhost ~]# # or
[root@localhost ~]# nginx -V

9 Use signals

9.1 Get pid

[root@localhost ~]# ps aux | grep nginx

# or 

[root@localhost ~]# cat /path/to/nginx.pid

9.2 Stop nginx gracefully and shut down the service after all requests are completed.

[root@localhost ~]# ps aux | grep nginx
[root@localhost ~]# kill -QUIT  pid

9.3 nginx quick stop command and shut down the process immediately

[root@localhost ~]# ps aux | grep nginx
[root@localhost ~]# kill -TERM pid
9.4 nginx force stop command

[root@localhost ~]# kill -9 pid
9.5 Graceful restart

Please note that you need to test the configuration file before reloading

When nginx receives the HUP signal, it will try to parse the configuration file first (if a configuration file is specified, use the specified one, > otherwise use the default one), and if successful, apply the new configuration file (for example: reopen the log file or listening socket > word). Afterwards, nginx runs the new worker process and gracefully shuts down the old worker process. Notifies the worker process to close the listening socket> but continue to serve currently connected clients. After all client services are completed, the old worker process is shut down. > If application of the new configuration file fails, nginx will continue to work using the old configuration.

[root@localhost ~]# nginx -t

[root@localhost ~]# ps aux | grep nginx
[root@localhost ~]# kill -HUP pid
# or
[root@localhost ~]# nginx -s reload

9.6 Appendix: Signals

The main process can handle the following signals:
TERM, INT quick shutdown
QUIT graceful shutdown
HUP restart Download the configuration, start a new working process with the new configuration, and calmly close the old working process
USR1 Reopen the log file USR2 Smoothly upgrade the executable program.
WINCH gracefully shut down the working process

[root@localhost ~]# kill -l
 1) SIGHUP   2) SIGINT   3) SIGQUIT  4) SIGILL   5) SIGTRAP
 6) SIGABRT  7) SIGBUS   8) SIGFPE   9) SIGKILL 10) SIGUSR1
11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM
16) SIGSTKFLT   17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP
21) SIGTTIN 22) SIGTTOU 23) SIGURG  24) SIGXCPU 25) SIGXFSZ
26) SIGVTALRM   27) SIGPROF 28) SIGWINCH    29) SIGIO   30) SIGPWR
31) SIGSYS  34) SIGRTMIN    35) SIGRTMIN+1  36) SIGRTMIN+2  37) SIGRTMIN+3
38) SIGRTMIN+4  39) SIGRTMIN+5  40) SIGRTMIN+6  41) SIGRTMIN+7  42) SIGRTMIN+8
43) SIGRTMIN+9  44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13
48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12
53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9  56) SIGRTMAX-8  57) SIGRTMAX-7
58) SIGRTMAX-6  59) SIGRTMAX-5  60) SIGRTMAX-4  61) SIGRTMAX-3  62) SIGRTMAX-2

Guess you like

Origin blog.csdn.net/risen16/article/details/78187289
Recommended