zoukankan      html  css  js  c++  java
  • nginx启动、重启、关闭

    一.启动

    cd usr/local/nginx/sbin
    ./nginx

    二.重启

    更改配置重启nginx

    kill -HUP 主进程号或进程号文件路径

    或者使用

    cd /usr/local/nginx/sbin
    ./nginx -s reload

    判断配置文件是否正确 

    nginx -t -c /usr/local/nginx/conf/nginx.conf

    或者

    cd /usr/local/nginx/sbin
    ./nginx -t

    三.关闭

    查询nginx主进程号

    ps -ef | grep nginx

    从容停止 kill -QUIT 主进程号

    快速停止 kill -TERM 主进程号

    强制停止 kill -9 nginx

    若nginx.conf配置了pid文件路径,如果没有,则在logs目录下

    kill -信号类型 '/usr/local/nginx/logs/nginx.pid'

    四.升级

    1.先用新程序替换旧程序文件

    2.kill -USR2 旧版程序的主进程号或者进程文件名

            此时旧的nginx主进程会把自己的进程文件改名为.oldbin,然后执行新版nginx,此时新旧版本同时运行

    3.kill -WINCH 旧版本主进程号

    4.不重载配置启动新/旧工作进程

            kill -HUP 旧/新版本主进程号

            从容关闭旧/新进程,kill -QUIT 旧/新进程号

            快速关闭旧/新进程,kill -TERM 旧/新进程号

    五.实际应用中经常使用

    实际应用中经常是关闭,再启动,nginx的启动命令是:

    /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

    -c制定配置文件的路径,不加-nginx会自动加载默认路径的配置文件。

    以上是通用的启动命令,研究了一下nginx帮助后发现,有-s参数可对nginx服务进行管理:

    # /usr/local/nginx/sbin/nginx -h
    nginx version: nginx/0.7.63
    Usage: nginx [-?hvVt] [-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
    -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

    于是可通过执行如下命令重启nginx

    # /usr/local/nginx/sbin/nginx -s reload
  • 相关阅读:
    Js中的变量
    flash读取XML 背景自动适应大小
    Ajax.NET Professional
    JS事件大全
    (转)SharePoint社区工具包中文版发布!!
    .iOS APP Project or Mac APP Project编译错误提示: My Mac 64bit is not valid for Running the scheme
    NSAssert断言
    iphone手机appstore地区更改
    自定义UITableView Section 的title样式字体
    从项中复制值
  • 原文地址:https://www.cnblogs.com/flyingeagle/p/5789308.html
Copyright © 2011-2022 走看看