ELAdmin 部署

后端部署

按需修改 application-prod.yml

例如验证码方式、登录状态到期时间等等。

修改完成后打好 Jar 包

执行完成后会生成最终可执行的 jar。JPA版本是 2.6,MyBatis 版本是 1.1。

启动命令

bash 复制代码
nohup java -jar eladmin-system-2.6.jar --spring.profiles.active=prod > nohup.out 2>&1 &

如果使用了CICD 工具,可能还需要停止的

bash 复制代码
PID=$(ps -ef | grep eladmin-system-1.1.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

配置 nginx,可以是 http的 80 端口,也可以是 https的 443 端口。

bash 复制代码
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";
        }
    }

如果是 443

bash 复制代码
    server {
        listen       443 ssl;
        server_name  eladmin.luotayixing.com;
        ssl_certificate      ssl/eladmin.luotayixing.com_bundle.crt;
        ssl_certificate_key  ssl/eladmin.luotayixing.com.key;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;

        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";
        }
    }

另外,nginx头部需要指定用户,默认是 nobody,可以换成对应用户,测试可以用 root

bash 复制代码
#user  nobody;
user root;

前端部署

鉴于本人前端能力实在有限,只测试了History 模式的,这里也不会介绍 Hash模式。

前面已经将后端部署上了,如果要本地启动的时候直接访问后端的接口,就需要修改.env.development,比如改成下面这样(如要后端配置了 80 端口,或者 80 和 443 都配置了)

bash 复制代码
ENV = 'development'

# 接口地址
# VUE_APP_BASE_API  = 'http://localhost:8000'
# VUE_APP_WS_API = 'ws://localhost:8000'
VUE_APP_BASE_API  = 'http://eladmin.luotayixing.com'
VUE_APP_WS_API = 'ws://eladmin.luotayixing.com'

# 是否启用 babel-plugin-dynamic-import-node插件
VUE_CLI_BABEL_TRANSPILE_MODULES = true

构建之前,修改下.env.production,比如改成 https 的

bash 复制代码
ENV = 'production'

# 如果使用 Nginx 代理后端接口,那么此处需要改为 '/',文件查看 Docker 部署篇,Nginx 配置
# 接口地址,注意协议,如果你没有配置 ssl,需要将 https 改为 http
VUE_APP_BASE_API  = 'https://eladmin.luotayixing.com'
# 如果接口是 http 形式, wss 需要改为 ws
VUE_APP_WS_API = 'wss://eladmin.luotayixing.com'

执行npm run build:prod,或者用 idea,打开 package.json,点击对应行前面的箭头

执行完成后,根目录下的 dist 就是生成好的,可以放到服务器上

配置 nginx,如果是 80端口

bash 复制代码
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;
        }  
    } 

如果是 443 端口

bash 复制代码
    server {
        listen       443 ssl;
        server_name  mp.luotayixing.com;
        ssl_certificate      ssl/mp.luotayixing.com_bundle.crt;
        ssl_certificate_key  ssl/mp.luotayixing.com.key;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;

        index index.html;
        root  /root/eladmin/dist/;
        location / {
          try_files $uri $uri/ @router;
          index  index.html;
        }
        location @router {
          rewrite ^.*$ /index.html last;
        }
    }

完成后重启 nginx,访问配置好的域名,比如本人的是https://mp.luotayixing.com/

相关推荐
念越32 分钟前
数据结构:栈堆
java·开发语言·数据结构
千寻技术帮1 小时前
10333_基于SpringBoot的家电进存销系统
java·spring boot·后端·源码·项目·家电进存销
dear_bi_MyOnly1 小时前
【多线程——线程状态与安全】
java·开发语言·数据结构·后端·中间件·java-ee·intellij-idea
jiaguangqingpanda1 小时前
Day36-20260204
java·开发语言
tb_first1 小时前
万字超详细苍穹外卖学习笔记4
java·spring boot·笔记·学习·spring·mybatis
努力写代码的熊大1 小时前
c++异常和智能指针
java·开发语言·c++
山岚的运维笔记1 小时前
SQL Server笔记 -- 第15章:INSERT INTO
java·数据库·笔记·sql·microsoft·sqlserver
Yvonne爱编码1 小时前
JAVA数据结构 DAY5-LinkedList
java·开发语言·python
小王不爱笑1322 小时前
LangChain4J 整合多 AI 模型核心实现步骤
java·人工智能·spring boot
西凉的悲伤2 小时前
spring-boot-starter-validation使用注解进行参数校验
java·spring boot·参数校验·validation·注解校验参数