vue+nginx配置

今天把本地的vue打包出来的dist文件配置到测试环境上了,运维用的是nginx。

首先, npm run build之后生成dist文件,放到服务器上,

其次,配置相应nginx.conf


server {

        listen 7070;

        server_name localhost;

        error_page 500 502 503 504 /50x.html;

        location = /50x.html {

              root html;

        }

       root D:/Project/demo/dist;

      #root /data/Project/demo/dist;

       index index.html;

        location / {

             try_files $uri $uri/ @router;

             index index.html;

        }

        location @router {

              rewrite ^.*$ /index.html last;

        }

}


这就可以访问啦, 服务器地址+端口+路由 localhost:7070/luyou

你可能感兴趣的:(vue+nginx配置)