1、基础命令
yiifung@localhost sbin]$ ./nginx -h
nginx version: nginx/1.22.1
Usage: nginx [-?hvVtTq] [-s signal] [-p prefix]
[-e filename] [-c filename] [-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: /home/yiifung/nginx/)
-e filename : set error log file (default: logs/error.log)
-c filename : set configuration file (default: conf/nginx.conf)
-g directives : set global directives out of configuration file
[yiifung@localhost sbin]$
2、命令详解
Command | Options | Description |
---|---|---|
./nginx | -?,-h | 帮助,获取详细信息 |
./nginx | -v | 获取版本信息 |
./nginx | -V | 获取版本信息以及configure的各种选项 |
./nginx | -t | 检查配置文件,是否符合语法规则 |
./nginx | -s | 发送信号给主进程,stop 快速的shutdown掉服务、quit 优雅的杀掉服务、reload重新加载配置文件、reopen切割日志文件,重新打开日志文件,防止日志文件过大,不方便查找也不方便归档 |
nginx -s reopen 详解
先将原来的日志重新命名,然后nginx -s reopen
yiifung@localhost logs]$ ll
total 12
-rw-r--r--. 1 yiifung yiifung 92 May 22 07:14 access.log
-rw-r--r--. 1 yiifung yiifung 1579 May 22 07:20 error.log
-rw-r--r--. 1 yiifung yiifung 6 May 22 07:18 nginx.pid
[yiifung@localhost logs]$ mv access.log access.log_22
[yiifung@localhost logs]$ mv error.log error.log_22
[yiifung@localhost logs]$ ll
total 12
-rw-r--r--. 1 yiifung yiifung 92 May 22 07:14 access.log_22
-rw-r--r--. 1 yiifung yiifung 1579 May 22 07:20 error.log_22
-rw-r--r--. 1 yiifung yiifung 6 May 22 07:18 nginx.pid
[yiifung@localhost logs]$ ../sbin/nginx -s reopen
[yiifung@localhost logs]$ ll
total 16
-rw-r--r--. 1 yiifung yiifung 0 May 22 07:21 access.log
-rw-r--r--. 1 yiifung yiifung 92 May 22 07:14 access.log_22
-rw-r--r--. 1 yiifung yiifung 61 May 22 07:21 error.log
-rw-r--r--. 1 yiifung yiifung 1579 May 22 07:20 error.log_22
-rw-r--r--. 1 yiifung yiifung 6 May 22 07:18 nginx.pid