【问题标题】:Why is nginx duplicating the folder in the path为什么nginx会复制路径中的文件夹
【发布时间】:2021-11-15 22:29:23
【问题描述】:

我正在尝试使用 Nginx 配置管理员。这是我的 adminer.conf:

server {
  listen 80;
  
  location /adminer {
    root /usr/share/webapps/adminer;
    index index.php;
  }
}

但是,当我转到 localhost/adminer 时,我收到错误 /usr/share/webapps/adminer/adminer/index.php is not found (No such file or directory)

adminer 文件夹重复,我不知道为什么。该位置应解析为/usr/share/webapps/adminer/index.php

【问题讨论】:

  • 检查rootalias nginx 指令之间的区别。
  • @IvanShatsky 谢谢,alias 是我想要的

标签: linux nginx adminer


【解决方案1】:

位置应该是

  • //usr/share/webapps/adminerlocalhost
  • /adminer/usr/share/webappslocalhost/adminer
server {
  listen 80;
  
  location /adminer {
    root /usr/share/webapps/;
    index index.php;
  }
}

【讨论】:

  • 谢谢...这有效..第一次使用 nginx...如果我想将位置设置为/test 以获取localhost/test。 Nginx 似乎总是将test 作为目录的一部分,但我只希望它作为 URL 的一部分而不是根目录的一部分。
  • 没关系,alias 关键字回答了我上面的问题。
  • 不用担心每个人第一次做某事,而 nginx 需要一些不同寻常的心态!.. 通常你想创建自己的 nginx.conf,而默认的 include 会从它的位置创建许多文件在/etc/ 中,它可能会引入您不期望的路径,或者没有它会丢失一些您想要支持的mimetype 过滤等.. 我从未使用过alias,但如果它可能就是您所追求的有效!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-07-10
  • 1970-01-01
  • 1970-01-01
  • 2020-12-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多