Nginx前端部署配置

Nginx部署(针对vue项目)

  • 运行打包命令生成 dist 文件:npm run dev
  • 打开 nginx.conf文件,配置对应的信息
# nginx.conf

location / {
  root  C:\Users\Desktop\project\dist;
  index index.html index.htm;
  try_files $url $url/ @router; # 解决页面刷新404问题
}

location @router {
  rewrite ^.*$ /index.html last; # Vue项目路由不是真实存在的
}
  • 检查配置文件是否配置成功
  nginx -t -c D:\nginx-1.16.1\conf\nginx.conf

  # 启动nginx
  start nginx
posted @   小方块的世界  阅读(104)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
· SQL Server 2025 AI相关能力初探
· 为什么 退出登录 或 修改密码 无法使 token 失效
历史上的今天:
2019-02-06 Unresolved function or method require()
点击右上角即可分享
微信分享提示