ELADMIN 在线文档 ELADMIN 在线文档
  • 快速开始
  • 后端手册
  • 前端手册
  • 部署项目
常见问题
支持项目
特别鸣谢
在线体验 (opens new window)
作者动态 (opens new window)
  • 快速开始
  • 后端手册
  • 前端手册
  • 部署项目
常见问题
支持项目
特别鸣谢
在线体验 (opens new window)
作者动态 (opens new window)
  • 快速开始

    • 简介
    • 快速了解
    • 快速开始
  • 后端手册

    • 新增模块
    • 权限控制
    • 通用查询
    • 系统缓存
    • 异常处理
    • 系统日志
    • 数据权限
    • 定时任务
    • 代码生成
    • 运维管理
    • 系统工具
    • 其他杂项
  • 前端手册

    • 菜单路由
    • 自定义主键
    • 多字段排序
    • 隐藏操作按钮
    • 使用数据字典
    • 统一异常处理
    • 部分系统组件
  • 部署项目

    • 常规部署方式
      • 常规部署方式
        • 后端部署
        • 前端部署
        • 重启Nginx
    • 容器部署方式
目录

常规部署方式

# 常规部署方式

# 后端部署

# 修改配置

按需修改我们的 application-prod.yml,如需打开 Swagger ,那么需要将 enabled 设置为 true

swagger:
  enabled: true
1
2

# 打包项目

我们需要将项目打包好的 Jar 文件上传到服务器,步骤图如下:

image.jpg

image578bed89803bdfa9.jpg

# 编写脚本

编写脚本用于操作 java 服务

(1) 启动脚本 start.sh

nohup java -jar eladmin-system-2.6.jar --spring.profiles.active=prod > nohup.out 2>&1 &
1

(2) 停止脚本 stop.sh

PID=$(ps -ef | grep eladmin-system-2.6.jar | grep -v grep | awk '{ print $2 }')
if [ -z "$PID" ]
then
echo Application is already stopped
else
echo kill -9 $PID
kill -9 $PID
fi
1
2
3
4
5
6
7
8

(3) 查看日志脚本 log.sh

tail -f nohup.out
1

脚本创建完成后就可以操作 java 服务了

# 启动java
./start.sh
# 停止java服务
./stop.sh
# 查看日志
./log.sh
1
2
3
4
5
6

# 配置 nginx

我们可以使用 nginx 代理 java服务,添加配置

server {
    listen 80;
    server_name 域名/当前服务器外网IP;
    location / {
        proxy_pass http://127.0.0.1:8000; #这里的端口记得改成项目对应的哦
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Port $server_port;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        }
    }
1
2
3
4
5
6
7
8
9
10
11
12

# 前端部署

这里提供两个配置方式 [History、Hash] 的部署方式,首先修改接口地址,如果是 IP 地址,那么需要修改为外网 IP

# History 模式

项目默认是 History 模式,不需要做任何修改

image4285f15c9c2dfa96.jpg

# Hash 模式

# 1、修改 routers.js,取消 hash 的注释

image92197994858c5edd.jpg

# 2、修改根目录 vue.config.js 配置,取消 15 行的注释

imagee7ae12491c445923.jpg

# 打包项目

不管是将项目部署到 nginx 还是其他服务器,都需要先将项目打包

npm run build:prod
1

打包完成后会在根目录生成 dist 文件夹,我们需要将他上传到服务器中

# Nginx 配置

在 nginx/conf/nginx.conf 添加配置

# History 模式配置
server
    {
        listen 80;
        server_name 域名/外网IP;
        index index.html;
        root  /home/wwwroot/eladmin/dist;  #dist上传的路径
        # 避免访问出现 404 错误
        location / {
          try_files $uri $uri/ @router;
          index  index.html;
        }
        location @router {
          rewrite ^.*$ /index.html last;
        }  
    } 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Hash 模式配置
server {
	   listen       80;
	   server_name  域名/外网IP;

	   location / {
	      root   /home/wwwroot/eladmin/dist; #dist上传的路径
	      index  index.html;
	   }
}
1
2
3
4
5
6
7
8
9

# 二级目录部署

# Nginx 配置
server {
	   listen       80;
	   server_name  域名/外网IP;

	   location /dist {
	      root   /home/wwwroot/eladmin/test;
	      index  index.html;
	   }
}
1
2
3
4
5
6
7
8
9

文件目录 image

注意目录名称要与配置名称一致

image

# 重启Nginx

systemctl restart nginx
1

重启 nginx 后,访问你的域名或者IP地址即可

帮助我们改善此页面! (opens new window)
上次更新: 2022/08/02, 14:02:38
部分系统组件
容器部署方式

← 部分系统组件 容器部署方式→

Theme by Vdoing | Copyright © 2018-2022 知了博客
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式
×