zoukankan      html  css  js  c++  java
  • Nginx02---指令集实现静态文件服务器

    location

    实现静态服务器,就是root和alias命令,他们位于location文件块中,详细:https://www.jianshu.com/p/4be0d5882ec5

    root

    root后跟的指定目录是上级目录,并且该上级目录下要含有和location后指定名称的同名目录才行,末尾“/”加不加无所谓。

    location /c/ { 
          root /a/
    }

    如果访问站点http://location/c访问的就是/a/c目录下的站点信息。

    allias

    alias后跟的指定目录是准确的,并且末尾必须加“/”,否则找不到文件

    location /c/ { 

          alias /a/
    }

    如果访问站点http://location/c访问的就是/a/目录下的站点信息。

    写绝对路径

    root 指令

    location /dir/ 
    root root_path         ->  http://host/dir/file.txt  -> root_path/dir/file.txt
    

    alias 指令

    location /dir
    alias alias_path       ->  http://host /dir /file.txt  -> alias_path/file.txt
    
    location /dir/ 
    alias alias_path/      ->  http://host /dir/ file.txt  -> alias_path/file.txt


    index页面配置

    #设置虚拟主机默认访问的网页

    location / {
    root /var/www/;
    index index.htm index.html;
    }

    这样,当用户请求 / 地址时,Nginx 就会自动在 root 配置指令指定的文件系统目录下依次寻找 index.htm 和index.html 这两个文件。如果 index.htm 文件存在,则直接发起“内部跳转”到 /index.htm 这个新的地址;而如果 index.htm 文件不存在,则继续检查 index.html 是否存在。如果存在,同样发起“内部跳转”到/index.html;如果 index.html 文件仍然不存在,则放弃处理权给 content 阶段的下一个模块。

  • 相关阅读:
    uni-app 发起请求,Toast 消息提示 ,跳转页面
    uView初识
    uni-app初识
    docker目录 /var/lib/docker/containers 日志清理
    Linux中使用pigz工具更快的压缩和解压文件
    docker 修改默认网段
    LayaAir提示:版本不匹配!全局tsc(2.7.2)!=VS Code的语言服务(2.1.5)。可能出现不一致的编译错误
    C++ 格式化 浮点为字符串
    安装 ta-lib
    编译 python 代码
  • 原文地址:https://www.cnblogs.com/BlueFire-py/p/9037080.html
Copyright © 2011-2022 走看看