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 阶段的下一个模块。

  • 相关阅读:
    mysql权限管理
    centos 6.5安装node.js
    sublime 配置jade高亮显示
    解决国内npm依赖包安装慢的问题
    sublime text3配置node.js开发环境
    datepicker 时间戳转换问题
    关于c++正则表达式的用法
    Android系统binder机制的研究分析
    TCP/IP的分层复用问题
    关于设计模式中外观模式的研究以及关于设计模式中四大原则的理解
  • 原文地址:https://www.cnblogs.com/BlueFire-py/p/9037080.html
Copyright © 2011-2022 走看看