本帖最后由 倔强的一步 于 2017-10-19 14:36 编辑
[iyunv@peacemap01 nginx-1.12.2]# ps -ef |grep nginx
root 8624 1 0 10月17 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody 8625 8624 0 10月17 ? 00:00:00 nginx: worker process
nobody 8626 8624 0 10月17 ? 00:00:15 nginx: worker process
root 31149 27434 0 14:09 pts/0 00:00:00 grep --color=auto nginx
[iyunv@peacemap01 nginx-1.12.2]# cat /usr/local/nginx/logs/nginx.pid
8624
1.信号控制
nginx服务可接受的信号TERM或INT //快速停止nginx服务
QUIT //平缓停止nginx服务
HUP //改变配置文件,使用新的配置文件启动你那个进程,之后平缓停止原有进程,也就是所谓的“平滑重启”
USR1 //重读打开日志文件,常用于日志切割,在相关章节中会对此进一步说明
USR2 //使用新版本nginx文件启动服务,之后平缓停止原有nginx进程,也就是所谓的“平滑升级”
WINCH //平缓停止worker process,用于nginx服务器平滑升级。配合USR2使用
2.nginx服务的启动
[iyunv@peacemap01 nginx]# sbin/nginx -h
nginx version: lsn/1.10.3
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/) 指定nginx服务器路径前缀
-c filename : set configuration file (default: conf/nginx.conf)指定nginx配置值路径
-g directives : set global directives out of configuration file 指定nginx附加配置文件路径
3.加入服务启动项
#/usr/lib/systemd/system/nginx.service
[Unit] Description=The NGINX HTTP and reverse proxy server After=syslog.target network.target remote-fs.target nss-lookup.target
[Service] Type=forking PIDFile=/usr/local/nginx/logs/nginx.pid ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf ExecStart=/usr/local/nginx/sbin/nginx ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/bin/kill -s QUIT $MAINPID PrivateTmp=true
[Install] WantedBy=multi-user.target
# systemctl daemon-reload # systemctl start nginxi.service # systemctl status nginxi.service
持续更新。。。。
|