美文网首页
Nginx管理命令

Nginx管理命令

作者: 老猫头 | 来源:发表于2017-08-13 21:52 被阅读43次
来自网络
01
信号量
=========================

nginx服务运行时,会保持一个主进程和一个或者多个工作进程。
我们可以通过给Nginx服务主进程发送信号就可以控制服务的启停。

nginx服务可以接受的信号

信号 作用
TERM或INT 快速停止 Nginx服务
QUIT 平缓停止Nginx服务
HUP 使用新的配置文件启动进程,之后平缓停止原有进程,平滑重启
USR1 重新打开日志文件,常用于日志切割
USR2 使用新版本的Nginx文件启动服务,平滑升级
WINCH 平缓停止工作进程,升级时使用

向nginx服务主进程发送信号方式

  1. 使用nginx二进制文件
  2. 使用kill命令发送
 kill SIGNAL PID

02
二进制信号量管理
=========================

在Linux平台下,启动Nginx服务器直接运行安装目录下的sbin目录中的二进制文件即可。管理Linux也常用二进制文件发送信号量。

  • 查看二进制信号量
# ./sbin/nginx  -h
nginx version: nginx/1.11.6
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
  • -V
    打印版本号和配置并退出
  • -t
    测试配置正确性并退出
  • -q
    测试配置时只显示错误
  • -s single
    向主进程发送信号
    stop, quit, reopen, reload
  • -p
    指定Nginx服务器路径前缀
  • -c filename
    指定Nginx配置文件路径
  • -g directives
    指定Nginx附加配置文件路径

03
常用案例
=========================

  • 查看Nginx服务进程
[root@localhost nginx]# ps -ef |grep nginx
root      1767     1  0 05:31 ?        00:00:00 nginx: master process ./nginx
nobody    1768  1767  0 05:31 ?        00:00:00 nginx: worker process
root      2053  1741  0 05:44 pts/0    00:00:00 grep nginx
  • 查看Nginx版本信息
 [root@localhost nginx]# ./sbin/nginx  -v
 nginx version: nginx/1.11.6
  • 检测配置文件并平滑启动
[root@localhost nginx]# ./sbin/nginx  -t
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@localhost nginx]# ./sbin/nginx  -s reload

相关文章

  • nginx 命令

    安装nginx 禁止更新 更新Nginx 命令管理:

  • 聊聊nginx

    nginx源码安装 nginx命令 nginx命令添加到环境变量中 nginx配置项 nginx 日志管理 ngi...

  • kubernetes

    kubernetes 安装 常用命令 命令发布nginx ymal配置文件管理 pod的管理 service的管理...

  • Nginx管理命令

    nginx服务运行时,会保持一个主进程和一个或者多个工作进程。我们可以通过给Nginx服务主进程发送信号就可以控制...

  • nginx管理命令

    1.暂停nginx服务 sudo systemctl stop nginx 2.启动nginx服务 sudo sy...

  • Linux命令service - 系统服务管理(转)

    一、问题描述 1、安装完nginx后,无法使用service或systemctl命令管理nginx服务 二、问题...

  • systemd服务管理,编写systemd Unit文件

    熟悉systemctl常用命令 通过systemd管理shell脚本 通过systemd管理Nginx服务 熟悉s...

  • 资源管理方式

    1、命令式对象管理:直接使用命令去操作kubernetes资源 kubectl run nginx-pod --i...

  • brew下安装并且使用nginx

    使用 brew search nginx命令,搜索nginx 使用 brew install nginx命令,安...

  • Nginx教程(二)基本命令

    Nginx提供了一个命令行工具,来帮助我们管理Nginx的启动、停止、更新等行为,这个工具会随着Nginx的安装被...

网友评论

      本文标题:Nginx管理命令

      本文链接:https://www.haomeiwen.com/subject/dbverxtx.html