首页 > 其他 > 详细

nginx部署vue项目

时间:2021-05-05 11:53:36      阅读:24      评论:0      收藏:0      [点我收藏+]

打包vue项目

yarn build

转移文件

将打包生成的dist文件夹复制到nginx目中的html文件夹中

修改配置文件

conf 目录下的 nginx.conf 文件

    server {
        listen       3100;
        server_name  127.0.0.1;

        location / {
            root   D:/soft/nginx-1.18.0/html/dist; # 指定vue项目打包的绝对路径
            index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
# 调接口请求,反向代理,实现跨域
        location ^~ /api/ {
            proxy_pass  http://127.0.0.1:8080/;
        }
    }

重启nginx

cmd窗口 或者 管理员身份的powerShell 执行 nginx -s reload

nginx部署vue项目

原文:https://www.cnblogs.com/yezi-zq/p/14731236.html

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