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.

最新文章

  1. linux下mono的安装与卸载
  2. Hibernate 查询方式(HQL/QBC/QBE)汇总
  3. 本地测试AJAX请求
  4. 程序最多能new多少内存(2G内存里要放程序的5大区,HeapAlloc比new要快多了,而且超过2G的时候会告诉你)
  5. JNI与NDK简介
  6. Eclipse改变外观,护眼模式
  7. 用android-x86模拟器不能运行程序错误Tag:libc的问题
  8. 安装eclipse
  9. Cortex-M3学习日志(六) -- ADC实验
  10. android Activity切换动画效果
  11. IOS FMDB模糊查询
  12. ASP.NET Core 添加统一模型验证处理机制
  13. 【Android Studio安装部署系列】四十二、Android Studio使用Eclipse中的keystore为App签名
  14. Springboot 集成jpa使用
  15. python学习第一讲,python简介
  16. tableviewcell选中不变色。
  17. NoSql的三大基石:CAP理论&BASE&最终一致性
  18. stm32cube使用
  19. 菜品识别 SDK调用
  20. Unity3D实践系列08, MonoBehaviour类的各种触发事件

热门文章

  1. [BZOJ2648] SJY摆棋子 kd-tree
  2. 山东省第七届省赛 D题:Swiss-system tournament(归并排序)
  3. BZOJ 3223: Tyvj 1729 文艺平衡树-Splay树(区间翻转)模板题
  4. luoguP1991无线通讯网
  5. Codeforces #445 Div2 D
  6. Java 线程 锁
  7. HashCode()的作用
  8. [Atcoder Grand Contest 002] Tutorial
  9. CodeForces - 283E Cow Tennis Tournament
  10. 【动态规划】【记忆化搜索】CODEVS 1010 过河卒 2002年NOIP全国联赛普及组