前端应用部署
大约 1 分钟
由于采用分布式架构,多出了前端应用部署的步骤,安装包为.zip文件,需要上传到服务器,然后解压,使用 nginx 代理。
安装步骤
注意
如果项目名不想叫 basic-paper-cloud
,想要修改项目名,需要重新打包。
解压文件
将 basic-paper-cloud.zip
解压到 /usr/website
下,解压后文件夹名为 basic-paper-cloud
。这里要注意, basic-paper-cloud
目录下一定要有一个 index.html
,如果没有那么说明这个包有问题或多出了一层。
配置 nginx
在 nginx 配置文件的 server
模块中,添加如下配置:
# 前端静态文件部署配置
location /basic-paper-cloud {
root /usr/website; # 站点目录。
index index.html;
try_files $uri $uri/ /basic-paper-cloud/index.html;
# 静态资源缓存 8 小时
expires 8h;
}
# 针对需要不缓存的 index.html 文件的 location 块
location ~* /(basic-paper-cloud|webcall-cloud)/index.html$ {
root /usr/website;
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Expires 0;
}
这段配置是将 /basic-paper-cloud
路径下的所有请求都转发到 /usr/website/basic-paper-cloud
目录下,如果找不到文件,则返回 /basic-paper-cloud/index.html
。
重要
如果没有 webcall-cloud,可以删除 webcall-cloud
配置,直接使用 location /basic-paper-cloud/index.html
即可。
接口地址配置
这个只是静态页面,要实现功能需要与服务进行交互,全部的接口配置都在 application-config.js
中,如果需要修改,请修改此文件(只有将项目名不为 basic-paper-cloud
时需要修改,但此时也需要重新打包)。