nginx基础12

2022-05-12 23:08:47 浏览数 (2)

强制停止
代码语言:javascript复制
[root@h102 logs]# ps faux | grep nginx 
root     11974  0.0  0.0 103256   828 pts/0    S    15:45   0:00          _ grep nginx
root     11971  0.0  0.0  24316   680 ?        Ss   15:45   0:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody   11972  0.0  0.0  24728  1248 ?        S    15:45   0:00  _ nginx: worker process                                          
[root@h102 logs]# kill -9 11971 
[root@h102 logs]# ps faux | grep nginx 
root     11976  0.0  0.0 103256   828 pts/0    S    15:45   0:00          _ grep nginx
nobody   11972  0.0  0.0  24728  1340 ?        S    15:45   0:00 nginx: worker process                                          
[root@h102 logs]#

强制停止比较暴力,会导致worker进程仍然停留在系统中,并且还能被访问


检查配置

重启之前最好先检查一下配置,避免由于配置不合理而导致的服务不可用

代码语言:javascript复制
[root@h102 nginx]# sbin/nginx -h 
nginx version: nginx/1.9.5
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: conf/nginx.conf)
  -g directives : set global directives out of configuration file

[root@h102 nginx]# sbin/nginx  -t -c conf/nginx.conf
nginx: [emerg] unexpected end of file, expecting ";" or "}" in /usr/local/nginx/conf/nginx.conf:120
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
[root@h102 nginx]# sbin/nginx  -t -c conf/nginx.conf
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@h102 nginx]#

0 人点赞