windows下nginx配置静态文件

2021-02-04  本文已影响0人  田丰w

在 nginx.conf 里的配置

静态目录配置

server {
    listen 8001;
    server_name localhost;

    # root 不会吞掉 location 已经匹配的路径, 如:
    # localhost:8001/html/a -> D:/ngxin/html/a
    location /html {
        root   D:/ngxin;
        index  index.html index.htm;
    }

    # alias  会吞掉 location 已经匹配的路径, 如:
    # localhost:8001/imgs/a.jpg -> D:/ngxin/imgs/a.jpg
    location /imgs/ {
        alias   D:/ngxin/imgs/;
        autoindex on;
        autoindex_exact_size off;
        autoindex_localtime on;
    }
}

windows 下 nginx 目录结构对照

my@wsl$ tree
.
├── conf
│   ├── conf.d
│   │   └── localhost-8001.conf
│   ├── fastcgi.conf
│   ├── fastcgi_params
│   ├── koi-utf
│   ├── koi-win
│   ├── mime.types
│   ├── nginx.conf
│   ├── scgi_params
│   ├── uwsgi_params
│   └── win-utf
├── contrib
│   ├── README
│   ├── geo2nginx.pl
│   ├── unicode2nginx
│   │   ├── koi-utf
│   │   ├── unicode-to-nginx.pl
│   │   └── win-utf
│   └── vim
│       ├── ftdetect
│       │   └── nginx.vim
│       ├── ftplugin
│       │   └── nginx.vim
│       ├── indent
│       │   └── nginx.vim
│       └── syntax
│           └── nginx.vim
├── docs
│   ├── CHANGES
│   ├── CHANGES.ru
│   ├── LICENSE
│   ├── OpenSSL.LICENSE
│   ├── PCRE.LICENCE
│   ├── README
│   └── zlib.LICENSE
├── html
│   ├── 50x.html
│   └── index.html
├── logs
│   ├── access.log
│   ├── error.log
│   └── nginx.pid
├── nginx.exe
└── temp
    ├── client_body_temp
    ├── fastcgi_temp
    ├── proxy_temp
    ├── scgi_temp
    └── uwsgi_temp

参考

https://blog.csdn.net/nrsc272420199/article/details/89368951

上一篇 下一篇

猜你喜欢

热点阅读