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:
- Force terminating your server through:
|
- Open your nginx config file to edit:
|
- Specify the path of your pid file:
|
- After saving your change, start your server now:
|
- To confirm that your pid config has taken effect, you can cat your pid file and/or try to restart your server through
servicecommand:
|
As expected, you will see the screen out “OK” for your operations.
Failed to Stop or Restart Nginx Server Through Serevice Command(nginx进程不能停止重启)的更多相关文章
- Setting up Django and your web server with uWSGI and nginx
https://uwsgi.readthedocs.io/en/latest/tutorials/Django_and_nginx.html Setting up Django and your we ...
- [r]Setting up Django and your web server with uWSGI and nginx
Setting up Django and your web server with uWSGI and nginx This tutorial is aimed at the Django user ...
- 配置 nginx server 出现nginx: [emerg] "root" directive is duplicate in /etc/nginx/server/blogs.conf:7
在配置nginx 虚拟机时,执行 sudo /usr/sbin/nginx -t 报下面的错误: nginx: [emerg] nginx: configuration file /etc/nginx ...
- 把Nginx加为系统服务(service nginx start/stop/restart)
1.编写脚本,名为nginx #!/bin/sh # # nginx - this script starts and stops the nginx daemon # # chkconfig: - ...
- How To Set Up Nginx Server Blocks (Virtual Hosts) on Ubuntu
sudo apt-get update sudo apt-get install nginxsudo mkdir -p /var/www/example.com/html sudo chown -R ...
- TinyCore Nginx server with php-cgi and vsftpd
http://blog.matchgenius.com/tinycore-nginx-server-with-php-cgi-and-vsftpd/ Create fast testing serve ...
- nginx Server names
通配符名称 正則表達式名称 混合名称 优化 兼容性 server名称定义使用的server_name指令和决定哪个server块用于一个给定的请求. 參见"怎样Nginx处理一个请求&quo ...
- nginx的开机自启、server命令启动、nginx.conf配置
1.将Nginx设置为开机自动启动 a.当上面6步完成之后,说明安装已经完全成功了,但是每次开机我们面临的一个问题,就是每次都要执行命令(1: cd /usr/local/nginx/sbin/ ...
- 用Keepalived搭建双Nginx server集群,防止单点故障
综述: 浏览器访问虚拟IP: 192.168.1.57, 该虚拟IP被Keepalived接管,两个Keepalived进程分别运行在物理IP为192.168.1.56和192.168.1.59服务器 ...
随机推荐
- linux+win7双系统重装win7修复grub的办法
本人是debian+win7的双系统, 下面介绍下重装win7的整个过程以及遇到的一些小问题,在查阅相关博客和朋友的帮助下成功修复, 记录下以便以后有不时之需, 也希望能帮助到遇到同样问题的朋友! 首 ...
- UVA 11624 Fire!【两点BFS】
Joe works in a maze. Unfortunately, portions of the maze have caught on fire, and the owner of the m ...
- 几何+暴力【p1959】 遗址[NOI导刊2009普及(6)]
题目描述--> P1959 遗址_NOI导刊2009普及(6) 普通方法分析: 因为题目要求是找最大正方形(如果是长方形更麻烦. 讲真,题目不难,耗时间! 根据题目要求,我们要找的是正方形. 我 ...
- [CF403D]Beautiful Pairs of Numbers
题意:给定$n,k$,对于整数对序列$\left(a_1,b_1\right),\cdots,\left(a_k,b_k\right)$,如果$1\leq a_1\leq b_1\lt a_2\leq ...
- Problem B: 调用函数,输出100到200之间的所有素数
#include <stdio.h> int isPrime(unsigned int n)//定义素数函数 { int i; || n == ) ; ; i * i <= n; i ...
- 分布式缓存DistributedCache的使用
分布式缓存用于将使用的小文件首先分发到各个datanode节点上,然后利用map/reduce阶段的setup()方法将文件内容读入内存,加快程序执行.具体实现方法如下: http://demievi ...
- 安装scrapy报错问题解决
今天在安装scrapy时候,最后一步出现下面报错(操作系统为centerOS 6.4) error: Setup script exited with error: command 'gcc' fai ...
- 使用layer.js注意事项
一.使用时,将layer整个文件夹放置你站点的任何一个目录,layer.js 开发版,layer.min.js 压缩版,引入其中一个即可.css等其它文件无需引入. 二.如果您的js引入是通过合并处理 ...
- 《你不知道的 CSS》之等比例缩放的盒子
你肯定已经知道,对于一个 img 元素而言,你可以单独地修改它的 width 或者 height 属性来设置它的大小,同时图片的比例还能够保持不变. 如下图所示,最上面是原始大小的图片,下面两张则分别 ...
- 分布式架构高可用架构篇_activemq高可用集群(zookeeper+leveldb)安装、配置、高可用测试
原文:http://www.iteye.com/topic/1145651 从 ActiveMQ 5.9 开始,ActiveMQ 的集群实现方式取消了传统的Master-Slave 方式,增加了基于Z ...