• Failed to Stop or Restart Nginx Server Through Serevice Command(nginx进程不能停止重启)


    Many people are accustomed to start a Nginx web server through init scripts and then they can control the state of the server through service command, such as sudo service nginx restart. But sometimes unobvious config error makes the scripts failed to work. Here I will show an error related to pid directive in the config file of nginx, which defaultly located at /opt/nginx/conf/nginx.conf
    As ignored by many people, some init scripts assump there is a pid file of nginx located at /var/run/nginx.pid, but in the fact, the default pid file for nginx is /opt/nginx/logs/nginx.pid. Because the scripts can’t get the correct pid or even get nothing, they failed to stop the nginx process, some tasks dependent on it will be failed too, for example, you are not able to restart the server.

    To resolve this problem, you need to:

    1. Force terminating your server through:
     
    $ sudo service nginx destroy
    
    1. Open your nginx config file to edit:
     
    $ sudo vim /opt/nginx/conf/nginx.conf
    
    1. Specify the path of your pid file:
     
    # /opt/nginx/conf/nginx.conf
    pid /var/run/nginx.pid
    
    1. After saving your change, start your server now:
     
    $ sudo service nginx start
    
    1. To confirm that your pid config has taken effect, you can cat your pid file and/or try to restart your server through service command:
     
    $ cat /var/run/nginx.pid
    $ sudo service nginx restart
    

    As expected, you will see the screen out “OK” for your operations.

  • 相关阅读:
    找一个写心的地方!
    找一个写心的地方!
    CentOS 6.4最小安装
    poj 3013 Big Christmas Tree 最短路 dijkstra算法
    poj 2449 Remmarguts' Date 第K短路
    CCNUOJ 1010 The Almost Lucky Numbers
    Java容器学习心得Set容器
    CCNUOJ 1027 教你前缀
    我的第一个C++程序( C++语言程序设计项目任务书 )
    CCNUOJ 1031 数组操作(树状数组)
  • 原文地址:https://www.cnblogs.com/weifeng1463/p/9187277.html
Copyright © 2020-2023  润新知