1、下载nginx,将打包好的vue项目文件放到 nginx-1.20.2\html 文件夹里面
2、在 nginx-1.20.2\conf 文件夹下,修改 nginx.conf 文件的内容,也就是部署入口路由
nginx.conf :
server {
listen 80; // 设置运行端口
server_name example.com;
location / {
root /home/example/dist;
try_files $uri $uri/ @router; # 配置使用路由
index index.html index.htm;
}
# 路由配置信息 解决路由跳转失败
location @router {
rewrite ^.*$ /index.html last;
}
}