nginx 静态文件部署 极简版

nginx的html文件夹目录结构

 

 将html下的index.html文件分别放到三个文件夹中,稍作改动,以示区分

修改nginx.conf

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       8090;
        server_name  localhost;

        location /mobile {
            root   html;
            index  index.html index.htm;
        }
        
        location /circle {
            root   html;
            index  index.html index.htm;
        }
        
        location /knowledge {
            root   html;
            index  index.html index.htm;
        }
       
    }
}

保存,运行nginx

分别访问三个路径下的index.html

 

 

 

 

 

posted @ 2022-06-13 15:00  代码羡  阅读(274)  评论(0编辑  收藏  举报