|
|
|
# 前端部署文档
|
|
|
|
|
|
|
|
前端有3种部署方式,分别为自动化部署,手动部署和编译源码部署
|
|
|
|
|
|
|
|
## 1、准备工作
|
|
|
|
#### 准备一:下载安装包
|
|
|
|
|
|
|
|
目前最新安装包版本是1.0.1,下载地址: [码云下载](https://gitee.com/easyscheduler/EasyScheduler/attach_files/)
|
|
|
|
|
|
|
|
下载escheduler-ui-1.0.1.tar.gz后,解压后会产生dist目录,进入dist目录
|
|
|
|
> cd dist
|
|
|
|
|
|
|
|
#### 准备二:新建一个`.env`文件
|
|
|
|
|
|
|
|
在dist目录下新建一个`.env`文件,在文件里添加后端服务的ip地址和端口,用于跟后端交互,`.env`文件内容如下:
|
|
|
|
```
|
|
|
|
# 代理的接口地址(自行修改)
|
|
|
|
API_BASE = http://192.168.xx.xx:12345
|
|
|
|
|
|
|
|
# 如果您需要用ip访问项目可以把 "#" 号去掉(例)
|
|
|
|
#DEV_HOST = 192.168.xx.xx
|
|
|
|
```
|
|
|
|
|
|
|
|
## 2、部署
|
|
|
|
以下两种方式任选其一部署即可,推荐自动化部署
|
|
|
|
### 2.1 自动化部署
|
|
|
|
|
|
|
|
在前端项目根目录dist下编辑安装文件`vi install(线上环境).sh`(执行时,最好修改install(线上环境).sh为install-ui.sh,跟后端部署区分)
|
|
|
|
|
|
|
|
更改前端访问端口和后端代理接口地址
|
|
|
|
|
|
|
|
```
|
|
|
|
# 配置前端访问端口
|
|
|
|
esc_proxy="8888"
|
|
|
|
|
|
|
|
# 配置代理后端接口
|
|
|
|
esc_proxy_port="http://192.168.xx.xx:12345"
|
|
|
|
```
|
|
|
|
|
|
|
|
前端自动部署基于linux系统`yum`操作,部署之前请先安装更新`yum`
|
|
|
|
|
|
|
|
在前端项目根目录dist下执行`./install(线上环境).sh` 或者改名后的 `./install-ui.sh`
|
|
|
|
|
|
|
|
|
|
|
|
### 2.2 手动部署
|
|
|
|
|
|
|
|
安装epel源 `yum install epel-release -y`
|
|
|
|
|
|
|
|
安装Nginx `yum install nginx -y`
|
|
|
|
|
|
|
|
|
|
|
|
> #### nginx配置文件地址
|
|
|
|
```
|
|
|
|
/etc/nginx/conf.d/default.conf
|
|
|
|
```
|
|
|
|
> #### 配置信息(自行修改)
|
|
|
|
```
|
|
|
|
server {
|
|
|
|
listen 8888;# 访问端口
|
|
|
|
server_name localhost;
|
|
|
|
#charset koi8-r;
|
|
|
|
#access_log /var/log/nginx/host.access.log main;
|
|
|
|
location / {
|
|
|
|
root /xx/dist; # 上面前端解压的dist目录地址(自行修改)
|
|
|
|
index index.html index.html;
|
|
|
|
}
|
|
|
|
location /escheduler {
|
|
|
|
proxy_pass http://192.168.xx.xx:12345; # 接口地址(自行修改)
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
proxy_set_header x_real_ipP $remote_addr;
|
|
|
|
proxy_set_header remote_addr $remote_addr;
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
proxy_http_version 1.1;
|
|
|
|
proxy_connect_timeout 4s;
|
|
|
|
proxy_read_timeout 30s;
|
|
|
|
proxy_send_timeout 12s;
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
|
|
proxy_set_header Connection "upgrade";
|
|
|
|
}
|
|
|
|
#error_page 404 /404.html;
|
|
|
|
# redirect server error pages to the static page /50x.html
|
|
|
|
#
|
|
|
|
error_page 500 502 503 504 /50x.html;
|
|
|
|
location = /50x.html {
|
|
|
|
root /usr/share/nginx/html;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
> #### 重启Nginx服务
|
|
|
|
```
|
|
|
|
systemctl restart nginx
|
|
|
|
```
|
|
|
|
|
|
|
|
#### nginx命令
|
|
|
|
|
|
|
|
- 启用 `systemctl enable nginx`
|
|
|
|
|
|
|
|
- 重启 `systemctl restart nginx`
|
|
|
|
|
|
|
|
- 状态 `systemctl status nginx`
|
|
|
|
|
|
|
|
|
|
|
|
## 前端常见问题
|
|
|
|
#### 1. 上传文件大小限制
|
|
|
|
编辑配置文件 `vi /etc/nginx/nginx.conf`
|
|
|
|
```
|
|
|
|
# 更改上传大小
|
|
|
|
client_max_body_size 1024m
|
|
|
|
```
|