iotfs-威尼斯人最新

, 0 次修正,1217 次阅读, 最后更新于 2022年02月18日

关注 “云腾五洲” 公众号:只为更好的服务

### 宝塔面板部署教程

前端
1.在 “网站” 中添加站点,php 版本选择纯静态。
2.在 ruoyi-ui 目录中运行 npm run build:stage(构建测试环境)或 npm run build:prod(构建生产环境),生成 dist 目录。
3.将 dist 目录中所有文件复制到宝塔生成的网站文件目录。

后端
4.在宝塔面板软件商店中安装 java 项目管理器,安装 tomcat9。
5.将 pom.xml 中jar修改为war。
6.将 application.yml 中 profile: d:/ruoyi/uploadpath 修改为 profile: /home/ruoyi/uploadpath
7.在 ruoyi-vue\ruoyi\bin 目录中运行 package.bat,生成 war 文件。
8.将 war 文件复制到服务器/www/server/tomcat9/webapps 目录中,自动生成 ruoyi 目录。
9.停止 tomcat 服务器,将 root 目录删除,将生成的 ruoyi 目录更名为 root,启动 tomcat 服务
10.在宝塔面板网站设置 - 配置文件中修改:
若为构建的测试环境:
添加:

location /stage-api/{
   proxy_set_header host $http_host;
   proxy_set_header x-real-ip $remote_addr;
   proxy_set_header remote-host $remote_addr;
   proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
   proxy_pass http://127.0.0.1:8181/;
}

若为构建的生产环境:

添加:

location /prod-api/{
   proxy_set_header host $http_host;
   proxy_set_header x-real-ip $remote_addr;
   proxy_set_header remote-host $remote_addr;
   proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
   proxy_pass http://127.0.0.1:8181/;
}

11.nginx 刷新显示 404

html5 history 模式 vue-router 默认 hash 模式 —— 使用 url 的 hash 来模拟一个完整的 url,于是当 url 改变时,页面不会重新加载。

如果不想要很丑的 hash,我们可以用路由的 history 模式,这种模式充分利用 history.pushstate api 来完成 url 跳转而无须重新加载页面。

const router = new vuerouter({
  mode: 'history',
  routes: [...]
})

当你使用 history 模式时,url 就像正常的 url,例如 ,也好看!

不过这种模式要玩好,还需要后台配置支持。因为我们的应用是个单页客户端应用,如果后台没有正确的配置,当用户在浏览器直接访问 就会返回 404,这就不好看了。

所以呢,你要在服务端增加一个覆盖所有情况的候选资源:如果 url 匹配不到任何静态资源,则应该返回同一个 index.html 页面,这个页面就是你 app 依赖的页面。

#apache


  rewriteengine on
  rewritebase /
  rewriterule ^index\.html$ - [l]
  rewritecond %{request_filename} !-f
  rewritecond %{request_filename} !-d
  rewriterule . /index.html [l]

除了 mod_rewrite,你也可以使用 fallbackresource。

#nginx

location / {
  try_files $uri $uri/ /index.html;
}
https://router.vuejs.org/zh/guide/essentials/history-mode.html
https://www.cnblogs.com/st666/p/9968653.html
网站地图