zoukankan      html  css  js  c++  java
  • Nginx的启动、停止和重启

    启动

    启动代码格式:nginx安装目录地址 -c nginx配置文件地址

    例如:

    [root@sijizhen sbin]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

    停止

    nginx有三种停止方式:

    从容停止

    1.查看进程  ps -ef|grep nginx

    [root@sijizhen sbin]# ps -ef|grep nginx
    root      9862     1  0 01:04 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
    nobody    9863  9862  0 01:04 ?        00:00:00 nginx: worker process                                          
    root      9886  1612  0 01:15 pts/0    00:00:00 grep nginx

    2.杀死进程  

    [root@sijizhen sbin]# kill -QUIT 9862

    快速停止

    1、查看进程号

    [root@sijizhen sbin]# ps -ef|grep nginx
    root      9892     1  0 01:17 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
    nobody    9893  9892  0 01:17 ?        00:00:00 nginx: worker process                                          
    root      9895  1612  0 01:18 pts/0    00:00:00 grep nginx

    2.杀死进程

    [root@sijizhen sbin]# kill -TERM 9892

    强制停止

    [root@sijizhen sbin]# pkill -9 nginx

    重启

    1、验证nginx配置文件是否正确

    方法一:进入nginx安装目录sbin下,输入命令./nginx -t

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

    说明配置文件正确!

    方法二:在启动命令-c前加-t

    [root@sijizhen sbin]# /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服务

     方法一:进入nginx可执行目录sbin下,输入命令./nginx -s reload 即可

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

    方法二:查找当前nginx进程号,然后输入命令:kill -HUP 进程号 实现重启nginx服务

    [root@sijizhen sbin]# ps -ef|grep nginx
    root      9928     1  0 01:24 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
    nobody    9935  9928  0 01:25 ?        00:00:00 nginx: worker process                                          
    root      9938  1612  0 01:26 pts/0    00:00:00 grep nginx
    [root@sijizhen sbin]# kill -HUP 9928

    参考:https://www.cnblogs.com/codingcloud/p/5095066.html

    脚踏实地,仰望星空。
  • 相关阅读:
    下一周计划
    strategy模式
    Roc加载模块过程
    博客园开通了
    MO sample中的缓冲冲区的例子很简单的一个例子
    作为一个想成为程序员的人来说
    试试用live writer写博客到博客园
    Tomcat崩溃,无法访问
    The class Form1 can be designed, but is not the first class in the file.
    Exception in thread "Timer0" java.lang.NullPointerException
  • 原文地址:https://www.cnblogs.com/sijizhen/p/10579696.html
Copyright © 2011-2022 走看看