[root@panyu001 ~]# ps aux | grep nginx
root 2996 0.0 0.0 20548 628 ? Ss 06:07 0:00 nginx:master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody 2997 0.0 0.3 22992 3884 ? S 06:07 0:00 nginx: worker process
nobody 2998 0.0 0.3 22992 3460 ? S 06:07 0:00 nginx: worker process
root 4666 0.0 0.0 112720 976 pts/1 S+ 11:02 0:00 grep --color=auto nginx
信号量
kill -INT 2996 #Kill 强制关闭Nginx进程
kill QUIT 2996 #优雅的关闭进程
kill -HUP 2996 #改变配置文件,平滑重读配置文件,不重启Nginx的服务kill -HUP `cat /usr/local/nginx/logs/nginx.pid`
kill -USR1 2996 #重读日志文件 /usr/local/nginx/logs/access.log 所有访问信息
USR2 #平滑地升级
实验1:平滑重读配置文件
1.vim /usr/local/nginx/conf/nginx.conf 增加
location /
{
root html;
index ab.html index.html index.htm;
}
2.vim /usr/local/nginx/html/ab.html 增加
3.kill -HUP `cat /usr/local/nginx/logs/nginx.pid`
实验2:重读日志文件(日志切割与备份)
[root@tiejiang nginx]# mv logs/access.log logs/access.log.20180513
[root@tiejiang nginx]# touch logs/access.log
[root@tiejiang nginx]# kill -USR1 31861
二进制文件常用命令
[root@tiejiang nginx]# ./sbin/nginx -s reload 不重启服务,重新加载配置文件
[root@tiejiang nginx]# ./sbin/nginx -s stop 停止nginx服务。
[root@tiejiang nginx]# ./sbin/nginx -s reopen 重读日志文件,类似于USER1
[root@tiejiang nginx]# ./sbin/nginx -t 查看配置文件是否修改错误