1
0
mirror of synced 2025-12-20 12:18:02 +08:00
Files
AJ-Report/doc/docs/guide/quicklySeparate.md
2025-07-29 14:17:05 +08:00

185 lines
5.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
**前后端分离部署**
- 需要有一定的动手能力和排错能力
- 需要对nginx有一定了解
- 同一台机器部署前后端真心不需要分离部署
- **请根据自己的实际情况对下面的步骤和内容进行调整**
```
linux
git clone https://gitee.com/anji-plus/report.git
后端report-code
修改bootstrap.yml 修改数据库连接、上传下载地址、jwt令牌等信息
maven package
java -jar
前端report-ui
修改前端config连接
BASE_API: '"./"'改成自己后端服务所在机器的ip地址
npm install
npm run build
使用nginx转发
```
## linux部署后端
### 编译环境
- [Apache Maven] 3.5 <br>
- [Node.js]
- report1.5以下版本请使用 node<= V14
- report1.5及以上版本请使用 node>= V16
- [Jdk] 1.8 <br>
### 版本问题
已知以下版本存在兼容性问题,请不要使用
- openJdk
- Jdk 1.7及以下/11及以上jdk11部分版本有问题
- Mysql 8.08.0.23/26版本没有问题8.0.21版本存在问题)
### 克隆源码
git clone https://gitee.com/anji-plus/report.git <br>
![img9.png](../picture/quickly/img_9.png) <br>
**注**:不要下载发行版里面的 Source Code.zip <br>
### 修改mysql连接
report-core --> src --> main --> resources --> bootstrap.yml <br>
将关于mysql的连接配置信息换成你使用的IP:数据库名。 <br>
**注**请确认你的Mysql是否支持远程连接登陆用户是否有DDL权限 <br>
```yaml
datasource:
url: jdbc:mysql://127.0.0.1:3306/aj_report?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false
username: root
password: xxxxxxxx
```
## flyway
flyway是用于自动执行sql因为mysql版本及配置等问题flyway可能会执行失败。<br>
如果日志提示“FlywayInitialization”错误请修改为false并手动执行sqlreport-core --> src --> main --> resources --> db.migration<br>
```yaml
flyway:
enabled: false #是否开启flyway自动执行sql脚本默认false
```
### OSS配置
OSS底层已支持minio、amazonS3、nfs都配置的情况下优先级minio->amazonS3->nfs <br>
需要修改downloadPath和path <br>
```yaml
gaea:
subscribes:
oss: #文件存储 都配置的情况下优先级minio->amazonS3->nfs
enabled: true
##允许上传的文件后缀
file-type-white-list: .png|.jpg|.gif|.icon|.pdf|.xlsx|.xls|.csv|.mp4|.avi|.jpeg|.aaa|.svg
# 用于文件上传成功后生成文件的下载公网完整URLhttp://serverip:9095/file/download注意填写IP必须填写后端服务所在的机器IP
downloadPath: http://127.0.0.1:9095/file/download
nfs:
#上传对应本地全路径,注意目录不会自动创建,注意 Win是 \ 且有盘符linux是 / 无盘符,注意目录权限问题
path: /app/disk/upload/
```
### jwt秘钥
生产环境请自行修改,避免被远程伪造登录攻击 <br>
[随机密码生成器](http://www.chahuo.com/token-generator.html)
```yaml
Security:
# jwt密钥生产环境请自行修改避免被远程伪造登录攻击
jwtSecret: TybmmfrgsIqpPsBOYxvygCMVJWKNfDJU
```
### maven打包
直接使用 maven package 打包,打包完成如图所示<br>
![img10](../picture/quickly/img_10.png) <br>
**注 **
```
1、打包之前如果系统用的不止mysql数据源需要自己在pom文件中加入对应的数据库的驱动登陆系统之后数据源提示无驱动则选择通用JDBC数据源这里不做演示了
2、此方式不会打包 lib目录下的驱动详情可查看 "数据源->扩展"
```
### linux启动jar包
将上步生成的jar包上传至linux使用java -jar命令启动 <br>
**注**请确保你的linux有jdk1.8 <br>
## 前端编译
**注意:** 每个版本前端可能会有些需要手动调整的部分这里只写最公共的部分如果有差异请看对应版本的release文档。<br>
### install
进入前端目录report-ui <br>
![img11](../picture/quickly/img_11.png) <br>
执行 npm install <br>
### 修改config
目录地址report-ui --> config --> prod.env.js <br>
将BASE_API地址改成自己后端服务所在机器的ip地址 <br>
### build
执行 npm run build <br>
生成的前端dist目录文件在report-ui下面 <br>
![img12](../picture/quickly/img_12.png) <br>
### 前端部署
使用nginx做转发以下内容仅供参考
```text
server {
listen 443 ssl;
server_name xxx;
access_log "/var/log/nginx/report.access.log" main;
error_log "/var/log/nginx/report.cn.error.log" info;
ssl_certificate cert/xxx.report.pem;
ssl_certificate_key cert/xxx.report.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
client_max_body_size 600M;
client_body_buffer_size 10M;
client_header_buffer_size 512k;
large_client_header_buffers 16 512k;
proxy_buffer_size 1024k;
proxy_buffers 16 1024k;
proxy_busy_buffers_size 2048k;
proxy_temp_file_write_size 2048k;
location / {
index index.html;
proxy_pass http://127.0.0.1:9095;
try_files $uri $uri /index.html =404;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
```