当前位置: 首页 > news >正文

ubuntu 安装两个nginx实例时的坑,非默认nginx实例配置修改总也不生效的问题

一、问题

      由于工作需求xx云服务器上安装了两个nginx实例,突然有一天需要在非默认nginx上增加一个子站点,根据网上教程和原来的记录修改vi nginx.conf 后保存载总也不生效?

   怎么破?

二、过程记录

   假如:非默认nginx安装在  /usr/local/nginx

 那么我 第一步:cd 到/usr/local/nginx

            第二步:nginx -s reload

            第三步:sbin/nginx -c conf/nginx.conf

理论上是没有错的,初始没有任务效果

  三、解决要点

      我们始终要头脑清醒,不管当前在什么目录,默认命令肯定是招待默认实例

  即便当前目标是 非默认实例nginx路径,如果不指定路径,直接键入 nginx命令依然指向默认实例

   所以:

   

   假如:非默认nginx安装在  /usr/local/nginx

 那么我 第一步:cd 到/usr/local/nginx

            第二步: ./nginx -s reload

            第三步:sbin/nginx -c conf/nginx.conf

指定相对路径nginx路径配置生效:
root@iZuf644aq2mn3ba0k4ain8Z:/usr/local/nginx/sbin# ./nginx -s reload
root@iZuf644aq2mn3ba0k4ain8Z:/usr/local/nginx# sbin/nginx -c conf/nginx.conf--------------------------------
ot@iZuf644aq2mn3ba0k4ain8Z:/usr/local/nginx/sbin# nginx -s reload
root@iZuf644aq2mn3ba0k4ain8Z:/usr/local/nginx/sbin# ./nginx -s reload
root@iZuf644aq2mn3ba0k4ain8Z:/usr/local/nginx/sbin# ./nginx -c ./conf/nginx.conf
nginx: [emerg] mkdir() "./html/hls" failed (2: No such file or directory)
root@iZuf644aq2mn3ba0k4ain8Z:/usr/local/nginx/sbin# ./nginx -c ../conf/nginx.conf
nginx: [emerg] open() "/usr/local/nginx/../conf/nginx.conf" failed (2: No such file or directory)
root@iZuf644aq2mn3ba0k4ain8Z:/usr/local/nginx/sbin# cd ../
root@iZuf644aq2mn3ba0k4ain8Z:/usr/local/nginx# ls
client_body_temp  conf  fastcgi_temp  html  logs  proxy_temp  sbin  scgi_temp  uwsgi_temp
root@iZuf644aq2mn3ba0k4ain8Z:/usr/local/nginx# sgin/nginx -c conf/nginx.conf
-bash: sgin/nginx: No such file or directory
root@iZuf644aq2mn3ba0k4ain8Z:/usr/local/nginx# sbin/nginx -c conf/nginx.conf
nginx: [emerg] bind() to 0.0.0.0:1935 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1110 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1111 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1112 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1113 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1114 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1115 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1116 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1117 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1118 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1119 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8022 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1935 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1110 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1111 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1112 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1113 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1114 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1115 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1116 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1117 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1118 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1119 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8022 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1935 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1110 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1111 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1112 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1113 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1114 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1115 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1116 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1117 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1118 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1119 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8022 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1935 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1110 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1111 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1112 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1113 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1114 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1115 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1116 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1117 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1118 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1119 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8022 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1935 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1110 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1111 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1112 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1113 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1114 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1115 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1116 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1117 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1118 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:1119 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:8022 failed (98: Address already in use)
nginx: [emerg] still could not bind()
root@iZuf644aq2mn3ba0k4ain8Z:/usr/local/nginx# telnet 127.0.0.1 1116
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
Connection closed by foreign host.
root@iZuf644aq2mn3ba0k4ain8Z:/usr/local/nginx# 

要点是 第二步 “./”        

    第二步: ./nginx -s reload

只有增加"./" 才是指向实际 指定路径的 nginx  只要不加 “./” 或类似等同的路径限定符,都是默认nginx实例 nginx -s reload 兄弟们就是执行N次都是依然不生效

四、总结

          多nginx实例 时要点是 除了 默认实例外,始终要有路径限定符的概念,不可大意,不要迷糊,在此备忘,同时希望可以帮到兄弟们!不是能力问题,是实践问题!

五、拓展

     同理,我们默认控制nginx 开,关,状态查询命令,如下命令,如果不指定路径限定符,始终是默认实例状态,开,停,而不是非默认实例,

     systemctl  status  nginx 

    systemctl start nginx

   systemctl stop nginx 

  我们即要习惯默认实例的常用 命令,也要适应多个实例,非默认实例的路径限定关系

   正常的步骤应当是

cd 到/usr/local/nginx

    systemctl  status  ./nginx 

    systemctl start ./nginx

   systemctl stop ./nginx 


http://www.mrgr.cn/news/998.html

相关文章:

  • sentinel集成springcloud实现限流熔断
  • 机器学习-线性回归
  • AWS子账号的创建与管理:提升安全性与灵活性
  • C++:函数
  • C++函数重载(一)
  • LeetCode41.缺失的第一个正数
  • 低代码开发平台:技术概览、效率与质量的权衡及挑战与机遇
  • Elasticsearch 的数据备份与恢复
  • 智能跃迁:机器学习中的迁移策略全解析
  • Linux--传输层协议TCP
  • 【数据结构与算法】如何构建最小堆
  • Postman入门指南
  • SQL - 数据类型
  • 【Spark集群部署系列一】Spark local模式介绍和搭建以及使用(内含Linux安装Anaconda)
  • iPhone照片怎么导入电脑?一键导入毫不费力
  • 探索AI编程:Wordware与自然语言编程的无限可能
  • 机器学习-混淆矩阵
  • 区块链技术在Facebook中的潜力:未来趋势与挑战
  • 乌龟对对碰在线版
  • Python知识点:如何使用Kubernetes与Python进行容器编排