首页 > 其他 > 详细

Nginx 静态资源配置

时间:2020-06-13 14:55:47      阅读:33      评论:0      收藏:0      [点我收藏+]

1、配置静态前端工程

server {
        listen       80;
        server_name  localhost;

        location / {
            root   /home/files/uploadStaticResource/folder1;
            #root   html;
            index   index.html;
        }

     }

 folder1文件夹就是存放的前端工程,里面放着一个index.html文件 

 

2、配置资源

server {
        listen       80;
        server_name  localhost;

        location / {
            root   /home/files/uploadStaticResource/folder1;
            #root   html;
            index   index.html;
        }

        location /resource {
            root   /home/files/uploadStaticResource;
         }


     }

  在/home/files/uploadStaticResource文件夹下放着一个resource文件夹

技术分享图片

 

 访问测试:

技术分享图片

 

使用别名的方式配置静态资源

location /static {
            alias   /home/files/uploadStaticResource/resource;
         }

 访问方式: http://www.xxx.xx/static/imgs/1.jpg 

 

Nginx 静态资源配置

原文:https://www.cnblogs.com/linlf03/p/13113587.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!