1、yarn build打包vue项目
2、打开nginx.conf文件,配置对应的信息
# nginx.conf
location / {
root C:\Users\17542\Desktop\project-v2\dist;
index index.html index.htm;
try_files $uri $uri/ @router; # 解决页面刷新404问题
}
location @router {
rewrite ^.*$ /index.html last; # Vue项目路由不是真实存在的
}
3、检查配置文件是否配置成功
打开cmd
nginx -t -c C:\Users\Administrator\Downloads\nginx\nginx-1.21.6\conf\nginx.conf
运行后是 is successful 之后
start nginx #运行nginx