当前位置: 首页 > 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 

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • HTML及CSS面试题4
  • 66_1JSON【浏览器中处理JSON、Java中处理JSON(FastJSON、Jackson)】、Java中的bean
  • XML外部实体注入
  • 使用docxtemplater-image-module-free时支持动态获取图片大小
  • SpringBoot:将单体项目拆分成微服务项目
  • 【PGCCC】pg_bestmatch.rs:使用 BM25 提升您的 PostgreSQL 文本查询#PCA
  • Windows下添加开机启动项
  • Vue.js 中的指令(Vue自定义指令)
  • 在小程序添加公司官网访问
  • 使用 Vue 2 搭建后台管理系统
  • 学习计算机网络(五)——ICMP协议
  • 仕考网:考外省公务员可以调回本地吗?
  • 保研考研机试攻略:第三章——数学(2)
  • uView的u-notice-bar组件横向滚动不生效问题解决
  • 《AI视频类工具之八——​ 快剪辑》
  • 【Under-the-hood-ReactJS-Part0】React源码解读
  • docker python 配置
  • Git的一些常用操作
  • javascript 总结(常用工具类的封装)
  • JavaScript设计模式系列一:工厂模式
  • python 装饰器(一)
  • React-Native - 收藏集 - 掘金
  • React-redux的原理以及使用
  • SpriteKit 技巧之添加背景图片
  • vuex 笔记整理
  • 从输入URL到页面加载发生了什么
  • 分布式熔断降级平台aegis
  • 今年的LC3大会没了?
  • 力扣(LeetCode)965
  • 聊聊directory traversal attack
  • 使用前端开发工具包WijmoJS - 创建自定义DropDownTree控件(包含源代码)
  • 提醒我喝水chrome插件开发指南
  • 一个6年java程序员的工作感悟,写给还在迷茫的你
  • 正则与JS中的正则
  • 做一名精致的JavaScripter 01:JavaScript简介
  • ​Java并发新构件之Exchanger
  • # 日期待t_最值得等的SUV奥迪Q9:空间比MPV还大,或搭4.0T,香
  • #{}和${}的区别是什么 -- java面试
  • #100天计划# 2013年9月29日
  • #我与Java虚拟机的故事#连载01:人在JVM,身不由己
  • (1)Android开发优化---------UI优化
  • (Charles)如何抓取手机http的报文
  • (Demo分享)利用原生JavaScript-随机数-实现做一个烟花案例
  • (翻译)Entity Framework技巧系列之七 - Tip 26 – 28
  • (十八)用JAVA编写MP3解码器——迷你播放器
  • .desktop 桌面快捷_Linux桌面环境那么多,这几款优秀的任你选
  • .NET CLR基本术语
  • .net 连接达梦数据库开发环境部署
  • .NET/C# 使用反射调用含 ref 或 out 参数的方法
  • .NET企业级应用架构设计系列之应用服务器
  • /*在DataTable中更新、删除数据*/
  • [ CTF ] WriteUp- 2022年第三届“网鼎杯”网络安全大赛(白虎组)
  • [ linux ] linux 命令英文全称及解释
  • []新浪博客如何插入代码(其他博客应该也可以)
  • [1525]字符统计2 (哈希)SDUT