Nginx的启动,停止和重启

1、Nginx的启动

#nginx启动的命令格式
# -c 指定配置文件的地址
nginx可执行文件的目录  -c  n ginx的配置文件

#命令如下
[root@localhost sbin]# ./nginx -c /javasoft/nginx/conf/nginx.conf

2、Nginx的停止

Nginx服务器启动之后,要想让其停止运行,有三种方式。1.从容停止  2.快速停止 3.强制停止

1、从容停止

1、查看Nginx的主进程号
[root@localhost sbin]# ps -ef | grep nginx
root      7334     1  0 04:19 ?        00:00:00 nginx: master process ./nginx -c /usr/local/nginx/conf/nginx.conf
nobody    7335  7334  0 04:19 ?        00:00:00 nginx: worker process                      
root     30463  2665  0 04:29 pts/0    00:00:00 grep nginx
2、停止Nginx
[root@localhost sbin]# kill -QUIT 7334

2、快速停止

1、查看Nginx的主进程号
[root@localhost sbin]# ps -ef | grep nginx
root     30492     1  0 04:34 ?        00:00:00 nginx: master process ./nginx -c /usr/local/nginx/conf/nginx.conf
nobody   30493 30492  0 04:34 ?        00:00:00 nginx: worker process                      
root     30504  2665  0 04:37 pts/0    00:00:00 grep nginx
 2、停止Nginx
[root@localhost sbin]# kill -TERM 30492

3、强制停止

1、查看Nginx的进程号
[root@localhost sbin]# ps -ef | grep nginx
root     30521     1  0 04:40 ?        00:00:00 nginx: master process ./nginx -c /usr/local/nginx/conf/nginx.conf
nobody   30522 30521  0 04:40 ?        00:00:00 nginx: worker process                      
root     30533  2665  0 04:41 pts/0    00:00:00 grep nginx
2、停止Nginx
[root@localhost sbin]# kill -9 30521

3、Nginx的重启

Nginx服务器在运行的时候,若想对其进行重新启动,比如当我们修改了配置文件,需要让新配置文件生效,就得重启等。当然重启的原因有很多,让新配置文件生效只是重启的其中一个原因。下面我们通过实例来讲解一下具体如何重启。

       1、修改了配置文件后,先验证了配置文件的正确性,再重新启动

             1.1 第一个方法(-t理解为test,用于测试配置文件的正确性)

[root@localhost 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

             1.2 第二个方法

[root@localhost /]# /usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
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

       2、在配置文件的正确性下,重启Nginx服务器

             1.1 第一个方法

[root@localhost sbin]# ./nginx -s reload

            1.2 第二个方法

               1、查询Nginx的信号量

[root@localhost sbin]# ps -ef | grep nginx
root     30657     1  0 04:56 ?        00:00:00 nginx: master process ./nginx
nobody   30662 30657  0 04:56 ?        00:00:00 nginx: worker process
root     30669  2665  0 04:57 pts/0    00:00:00 grep nginx

                2、发送信号量,重启Nginx服务。以便于加载修改的配置文件的内容

[root@localhost sbin]# kill -HUP 30657

4、Nginx的启动,停止和重启的另一种方式

#Nginx启动的一个方式
nginx  -s  stop  / start / reload

5、Nginx的信号量

      1、Nginx的信号控制概述

   上面我们实现的Nginx服务器的启动、停止以及重启是用信号来控制的。这是一些简单的信号控制。在Nginx服务器中,通常情况都是通过对其发送控制信号进行控制的,除了以上所说的简单的信号控制之外,还有很多的信号控制。在此,我们需要知道,要想操作Nginx服务器,一般来说是对其发送信号来对其进行控制。

      2、Nginx常见的信号控制实战

         下面我们通过实例对Nginx常见的信号控制命令进行实战讲解

  1、HUP      重启
  2、QUIT      从容重启
  3、TERM     快速关闭
  4、INT       从容关闭
  5、USR1      切换日志文件(用于切换日志文件和切割日志文件)
  6、USR2      平滑升级可执行进行
  7、WINCH    从容关闭工作进程

 

 

 

2、Nginx常见的信号控制实战

  下面我们通过实例对Nginx常见的信号控制命令进行实战讲解

  1HUP      重启

  2QUIT      从容重启

  3TERM     快速关闭

  4INT       从容关闭

  5USR1      切换日志文件(用于切换日志文件和切割日志文件)

  6USR2      平滑升级可执行进行

  7WINCH    从容关闭工作进程



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值