Nginx支持一下命令行参数

-? | -h   打印出命令行参数的帮助

[root@localhost nginx]# ./nginx -?

nginx version: nginx/1.8.0

Usage: nginx [-?hvVtq] [-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

-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: /usr/local/nginx/nginx.conf)

-g directives : set global directives out of configuration file

[root@localhost nginx]# ./nginx -h

nginx version: nginx/1.8.0

Usage: nginx [-?hvVtq] [-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

-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: /usr/local/nginx/nginx.conf)

-g directives : set global directives out of configuration file

-c file  使用可用的配置文件而不是默认的文件

[root@localhost nginx]# pwd

/usr/local/nginx

[root@localhost nginx]# ls

client_body_temp        fastcgi_temp  mime.types.default  sbin                  uwsgi_temp

conf                    html          nginx               scgi_params           win-utf

fastcgi.conf            koi-utf       nginx.bak           scgi_params.default

fastcgi.conf.default    koi-win       nginx.conf          scgi_temp

fastcgi_params          logs          nginx.conf.default  uwsgi_params

fastcgi_params.default  mime.types    proxy_temp          uwsgi_params.default

[root@localhost nginx]# ./nginx -c nginx.conf

[root@localhost nginx]#

-t 不运行,而仅仅测试配置文件。Nginx将检查配置文件的语法的正确性,并尝试打开配置文件中所有引用的文件。

[root@localhost nginx]# ./nginx -t

nginx: the configuration file /usr/local/nginx/nginx.conf syntax is ok

nginx: configuration file /usr/local/nginx/nginx.conf test is successful

-v显示nginx的版本

[root@localhost nginx]# ./nginx -v

nginx version: nginx/1.8.0

-V显示nginx的版本,编译器版本和配置参数

[root@localhost nginx]# ./nginx -V

nginx version: nginx/1.8.0

built by gcc 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)

built with OpenSSL 1.0.1c 10 May 2012

TLS SNI support enabled

configure arguments: --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_stub_status_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_spdy_module --with-ipv6 --with-pcre=../pcre-8.37 --with-zlib=../zlib-1.2.8 --with-openssl=../openssl-1.0.1c --user=nginx --group=nginx

[root@localhost nginx]#

-s signal 发送一个信号给主进程,这些参数可以以下的参数中的一个:

./nginx –s stop

快速关闭

./nginx –s quit

优雅关闭

./nginx –s reload

重新加载配置文件,使用一个新的worker进程启动一个新的worker进程,优雅的关闭旧的worker进程。

./nginx –s reopen

重新打开日志文件

Nginx控制信号

可以使用信号系统来控制主进程。默认,nginx将其主进程的pid写入到/usr/local/nginx/nginx.pid文件中。通常传递参数给./configure或使用pid指令,来改变文件的位置。

主进程可以处理以下的信号:

TERM,INT

快速关闭

QUIT

从容关闭

HUP

重载配置

用新的配置开始新的工作进程从容关闭旧的工作进程。

USR1

重新打开日志文件

USR2

平滑升级可执行程序

WINCH

从容关闭工作进程

尽管你不币自己操作工作进程,但是,它们也支持一些信号:

TERM,INT

快速关闭

QUIT

从容关闭

USR1

重新打开日志文件

Nginx启动、停止、重启命令

Nginx启动

[root@localhost nginx]# pwd

/usr/local/nginx

[root@localhost nginx]# ls

client_body_temp        fastcgi_temp  mime.types.default  sbin                  uwsgi_temp

conf                    html          nginx               scgi_params           win-utf

fastcgi.conf            koi-utf       nginx.bak           scgi_params.default

fastcgi.conf.default    koi-win       nginx.conf          scgi_temp

fastcgi_params          logs          nginx.conf.default  uwsgi_params

fastcgi_params.default  mime.types    proxy_temp          uwsgi_params.default

[root@localhost nginx]# ./nginx

[root@localhost nginx]#

Nginx从容停止命令,等待所有请求结束后关闭服务:

ps –ef | grep nginx

kill –QUIT nginx主进程号

[root@localhost nginx]# ps -ef | grep nginx

root     18252     1  0 15:35 ?        00:00:00 nginx: master process ./nginx

nginx    18253 18252  0 15:35 ?        00:00:00 nginx: worker process

nginx    18254 18252  0 15:35 ?        00:00:00 nginx: worker process

root     18304 14028  0 15:37 pts/0    00:00:00 grep nginx

[root@localhost nginx]# kill -QUIT 18252

[root@localhost nginx]# ps -ef | grep nginx

root     18389 14028  0 15:40 pts/0    00:00:00 grep nginx

[root@localhost nginx]# ./nginx

[root@localhost nginx]# ps -ef | grep nginx

root     18393     1  0 15:40 ?        00:00:00 nginx: master process ./nginx

nginx    18394 18393  0 15:40 ?        00:00:00 nginx: worker process

nginx    18395 18393  0 15:40 ?        00:00:00 nginx: worker process

root     18399 14028  0 15:40 pts/0    00:00:00 grep nginx

[root@localhost nginx]# kill -QUIT `cat /usr/local/nginx/nginx.pid`

[root@localhost nginx]# ps -ef | grep nginx

root     18447 14028  0 15:42 pts/0    00:00:00 grep nginx

[root@localhost nginx]#

Nginx快速停止命令,立刻关闭nginx进程

ps -ef | grep nginx

kill –TERM nginx主进程号

[root@localhost nginx]# ./nginx

[root@localhost nginx]# ps -ef | grep nginx

root     18503     1  0 15:44 ?        00:00:00 nginx: master process ./nginx

nginx    18504 18503  0 15:44 ?        00:00:00 nginx: worker process

nginx    18505 18503  0 15:44 ?        00:00:00 nginx: worker process

root     18508 14028  0 15:44 pts/0    00:00:00 grep nginx

[root@localhost nginx]# kill -TERM 18503

[root@localhost nginx]# ps -ef | grep nginx

root     18557 14028  0 15:46 pts/0    00:00:00 grep nginx

[root@localhost nginx]#

如果以上命令不管用,可以强制停止:

Kill -9 nginx主进程号

如果嫌麻烦可以不用查看进程号,直接使用命令进行操作

其中/usr/local/nginx/nginx.pid为nginx.conf中的pid命令设置的参数,用来存放nginx主进程号的文件

Kill –信号类型(HUP|TERM|QUIT) `cat /usr/local/nginx/nginx.pid`

例如:

kill -QUIT `cat/usr/local/nginx/nginx.pid`

nginx重启命令:

1简单型,先关闭进程,修改你的配置后,重启进程。

kill -QUIT `cat/usr/local/nginx/nginx.pid`

./nginx

2 重新加载配置文件,不重启进程,不会停止处理请求

3 平滑更新nginx二进制,不会停止处理请求

04_Nginx命令行参数,控制信号,Nginx启动、停止、重启命令相关推荐

  1. python 命令行参数-Python 中最好用的命令行参数解析工具

    Python 做为一个脚本语言,可以很方便地写各种工具.当你在服务端要运行一个工具或服务时,输入参数似乎是一种硬需(当然你也可以通过配置文件来实现). 如果要以命令行执行,那你需要一个命令行参数解析的 ...

  2. python中的命令行参数_python学习笔记6:命令行参数

    1. 使用步骤 使用步骤如下: # 导入模块 import argparse # 获取parser, description文本会显示在help信息中 parser = argparse.Argume ...

  3. nginx启动停止重启

    nginx的启动停止与重启 启动:启动代码格式:nginx安装目录地址 -c nginx配置文件地址 [root@LinuxServer sbin]# /usr/local/nginx/sbin/ng ...

  4. linux下nginx启动停止重启控制脚本

    这是控制nginx服务的脚本文件,包括控制nginx的启动.重启.停止.平滑重启.对配置文件的额检查. [root@localhost ~]# cat nginx.sh #!/bin/env bash ...

  5. CentOS7中MySQL启动停止重启命令

    1.启动 mysql-5.7.37为mysql的安装目录 systemctl start mysqld.service [xiong@hadoop102 mysql-5.7.37]$ systemct ...

  6. 服务器MYSQL启动/停止/重启命令

    1.查看mysql版本 方法一:status; 方法二:select version(); 2.Mysql启动.停止.重启常用命令 a.启动方式 1.使用 service 启动: [root@loca ...

  7. nginx 启动/停止/重启 BAT

    cls @ECHO OFF SET NGINX_PATH=D: SET NGINX_DIR=D:\Hack\nginx\ color 0a TITLE Nginx 管理程序 Power By Ants ...

  8. linux添加cmd命令行参数,Windows 终端命令行参数 | Microsoft Docs

    使用 Windows 终端的命令行参数Using command-line arguments for Windows Terminal 06/18/2020 本文内容 可以使用 wt.exe 从命令 ...

  9. Windows API一日一练(一)第一个应用程序 使用应用程序句柄 使用命令行参数 MessageBox函数 RegisterClass和RegisterClassEx函数

    要跟计算机进行交互,就需要计算机显示信息给人看到,或者发出声音给人听到,然后人看到或听到相应的信息后,再输入其它信息给计算机,这样就可以让计算机进行数据处理,把结果显示给我们.现在就来编写一个最简单的 ...

  10. Windows 系统文件资源管理器的命令行参数(如何降权打开程序,如何选择文件)

    大多数用户还是习惯使用 Windows 自带的文件资源管理器来管理文件,于是我们可以利用它的命令行参数来帮助我们做一些与之相关的交互. 本文会以实际的例子来说明如何使用 explorer.exe 的命 ...

最新文章

  1. intellij2018使用2019的主题
  2. linux mk创建文件,Linux运维知识之Linux mkkickstart建立安装的组态文件命令详解
  3. C#比较dynamic和Dictionary性能
  4. 从PeopleEditor控件中取出多用户并更新到列表
  5. kibana 更新 索引模式_升级 Kibana - Kibana 中文文档
  6. mysql远程授权格式_MySQL远程访问授权
  7. python recv_[Python]关于socket.recv()的非阻塞用法
  8. cassandra学习笔记一
  9. 互联网运营数据分析(3): 留存分析
  10. 群晖使用ClouDNS免费DDNS解析
  11. C/C++语言函数之strlen函数用法
  12. 跟随鼠标移动-demo
  13. RAID-6技术详解
  14. Python基于人脸识别的考勤系统(附源码)
  15. JavaScript学习笔记——JS错误处理
  16. iphone开发每日一练【2011-10-11】
  17. ztree插件树状图
  18. 新书自序【人人都是产品经理:9073】
  19. 高德地图SDK使用经验
  20. 天龙八部服务器位置,天龙八部3教你找到你都在哪些服建过角色

热门文章

  1. Scrapy框架的学习(7. 了解Scrapy中的debug信息以及Scrapy shell的使用)
  2. python sklearn学习笔记大全(常见代码速查)
  3. OpenCASCADE绘制测试线束:几何命令之概述
  4. OpenCASCADE:Direct3D CSharp 示例
  5. boost::geometry::model::d3::point_xyz用法的测试程序
  6. boost::geometry::detail::copy_segments的用法测试程序
  7. GDCM:将PAPYRUS 3.0文件转换为dcm文件的的测试程序
  8. DCMTK:全局类型和常量定义
  9. VTK:Utilities之SortDataArray
  10. VTK:PolyData之ThresholdPoints