[root@test-02 ~]# cd /www/webapps/ [root@test-02 webapps]# ll total 0 drwxr-xr-x 13 root root 284 Aug 24 15:10 RuoYi-Vue [root@test-02 webapps]# git clone https://gitee.com/y_project/RuoYi-Vue.git Cloning into 'RuoYi-Vue'... remote: Enumerating objects: 8880, done. remote: Total 8880 (delta 0), reused 0 (delta 0), pack-reused 8880 Receiving objects: 100% (8880/8880), 2.72 MiB | 674.00 KiB/s, done. Resolving deltas: 100% (4500/4500), done. [root@test-02 webapps]# ll RuoYi-Vue/ total 32 drwxr-xr-x 2 root root 57 Aug 27 11:27 bin drwxr-xr-x 2 root root 43 Aug 27 11:27 doc -rw-r--r-- 1 root root 1071 Aug 27 11:27 LICENSE -rw-r--r-- 1 root root 9720 Aug 27 11:27 pom.xml -rw-r--r-- 1 root root 5814 Aug 27 11:27 README.md drwxr-xr-x 3 root root 32 Aug 27 11:27 ruoyi-admin drwxr-xr-x 3 root root 32 Aug 27 11:27 ruoyi-common drwxr-xr-x 3 root root 32 Aug 27 11:27 ruoyi-framework drwxr-xr-x 3 root root 32 Aug 27 11:27 ruoyi-generator drwxr-xr-x 3 root root 32 Aug 27 11:27 ruoyi-quartz drwxr-xr-x 3 root root 32 Aug 27 11:27 ruoyi-system drwxr-xr-x 6 root root 283 Aug 27 11:27 ruoyi-ui -rw-r--r-- 1 root root 1639 Aug 27 11:27 ry.bat -rw-r--r-- 1 root root 1724 Aug 27 11:27 ry.sh drwxr-xr-x 2 root root 47 Aug 27 11:27 sql
导入数据库数据
[root@test-02 webapps]# ll RuoYi-Vue/sql/ total 68 -rw-r--r-- 1 root root 12066 Aug 27 11:27 quartz.sql -rw-r--r-- 1 root root 55105 Aug 27 11:27 ry_20210731.sql [root@test-02 webapps]# pwd /www/webapps [root@test-02 webapps]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 336 Server version: 5.7.35 MySQL Community Server (GPL) Copyright (c) 2000, 2021, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
先创建数据库
mysql> create database `ry-vue` character set utf8mb4; Query OK, 1 row affected (0.00 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | ry | | ry-vue | | sys | +--------------------+ 6 rows in set (0.00 sec)
再导入数据
mysql> use ry-vue Database changed mysql> source /www/webapps/RuoYi-Vue/sql/quartz.sql mysql> show tables; +--------------------------+ | Tables_in_ry-vue | +--------------------------+ | QRTZ_BLOB_TRIGGERS | | QRTZ_CALENDARS | | QRTZ_CRON_TRIGGERS | | QRTZ_FIRED_TRIGGERS | | QRTZ_JOB_DETAILS | | QRTZ_LOCKS | | QRTZ_PAUSED_TRIGGER_GRPS | | QRTZ_SCHEDULER_STATE | | QRTZ_SIMPLE_TRIGGERS | | QRTZ_SIMPROP_TRIGGERS | | QRTZ_TRIGGERS | +--------------------------+ 11 rows in set (0.01 sec) mysql> source /www/webapps/RuoYi-Vue/sql/ry_20210731.sql mysql> show tables; +--------------------------+ | Tables_in_ry-vue | +--------------------------+ | QRTZ_BLOB_TRIGGERS | | QRTZ_CALENDARS | | QRTZ_CRON_TRIGGERS | | QRTZ_FIRED_TRIGGERS | | QRTZ_JOB_DETAILS | | QRTZ_LOCKS | | QRTZ_PAUSED_TRIGGER_GRPS | | QRTZ_SCHEDULER_STATE | | QRTZ_SIMPLE_TRIGGERS | | QRTZ_SIMPROP_TRIGGERS | | QRTZ_TRIGGERS | | gen_table | | gen_table_column | | sys_config | | sys_dept | | sys_dict_data | | sys_dict_type | | sys_job | | sys_job_log | | sys_logininfor | | sys_menu | | sys_notice | | sys_oper_log | | sys_post | | sys_role | | sys_role_dept | | sys_role_menu | | sys_user | | sys_user_post | | sys_user_role | +--------------------------+ 30 rows in set (0.00 sec) mysql> exit Bye
修改MySQL连接串
[root@test-02 webapps]# cat RuoYi-Vue/ruoyi-admin/src/main/resources/application-druid.yml # 数据源配置 spring: datasource: type: com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver druid: # 主库数据源 master: url: jdbc:mysql://10.0.0.72:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: root password: e2_ABYAwQZlAF # 从库数据源 slave: # 从数据源开关/默认关闭 enabled: false url: username: password: # 初始连接数 initialSize: 5 # 最小连接池数量 minIdle: 10 # 最大连接池数量 maxActive: 20 # 配置获取连接等待超时的时间 maxWait: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 timeBetweenEvictionRunsMillis: 60000 # 配置一个连接在池中最小生存的时间,单位是毫秒 minEvictableIdleTimeMillis: 300000 # 配置一个连接在池中最大生存的时间,单位是毫秒 maxEvictableIdleTimeMillis: 900000 # 配置检测连接是否有效 validationQuery: SELECT 1 FROM DUAL testWhileIdle: true testOnBorrow: false testOnReturn: false webStatFilter: enabled: true statViewServlet: enabled: true # 设置白名单,不填则允许所有访问 allow: url-pattern: /druid/* # 控制台管理用户名和密码 login-username: ruoyi login-password: 123456 filter: stat: enabled: true # 慢SQL记录 log-slow-sql: true slow-sql-millis: 1000 merge-sql: true wall: config: multi-statement-allow: true
修改redis连接串(redis的地址和redis密码)
[root@test-02 webapps]# cat RuoYi-Vue/ruoyi-admin/src/main/resources/application.yml # 项目相关配置 ruoyi: # 名称 name: RuoYi # 版本 version: 3.6.0 # 版权年份 copyrightYear: 2021 # 实例演示开关 demoEnabled: true # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) profile: D:/ruoyi/uploadPath # 获取ip地址开关 addressEnabled: false # 验证码类型 math 数组计算 char 字符验证 captchaType: math # 开发环境配置 server: # 服务器的HTTP端口,默认为8080 port: 8080 servlet: # 应用的访问路径 context-path: / tomcat: # tomcat的URI编码 uri-encoding: UTF-8 # tomcat最大线程数,默认为200 max-threads: 800 # Tomcat启动初始化的线程数,默认值25 min-spare-threads: 30 # 日志配置 logging: level: com.ruoyi: debug org.springframework: warn # Spring配置 spring: # 资源信息 messages: # 国际化资源文件路径 basename: i18n/messages profiles: active: druid # 文件上传 servlet: multipart: # 单个文件大小 max-file-size: 10MB # 设置总上传的文件大小 max-request-size: 20MB # 服务模块 devtools: restart: # 热部署开关 enabled: true # redis 配置 redis: # 地址 host: 10.0.0.72 # 端口,默认为6379 port: 6379 # 数据库索引 database: 0 # 密码 password: Tang2020 # 连接超时时间 timeout: 10s lettuce: pool: # 连接池中的最小空闲连接 min-idle: 0 # 连接池中的最大空闲连接 max-idle: 8 # 连接池的最大数据库连接数 max-active: 8 # #连接池最大阻塞等待时间(使用负值表示没有限制) max-wait: -1ms # token配置 token: # 令牌自定义标识 header: Authorization # 令牌密钥 secret: abcdefghijklmnopqrstuvwxyz # 令牌有效期(默认30分钟) expireTime: 30 # MyBatis配置 mybatis: # 搜索指定包别名 typeAliasesPackage: com.ruoyi.**.domain # 配置mapper的扫描,找到所有的mapper.xml映射文件 mapperLocations: classpath*:mapper/**/*Mapper.xml # 加载全局的配置文件 configLocation: classpath:mybatis/mybatis-config.xml # PageHelper分页插件 pagehelper: helperDialect: mysql supportMethodsArguments: true params: count=countSql # Swagger配置 swagger: # 是否开启swagger enabled: true # 请求前缀 pathMapping: /dev-api # 防止XSS攻击 xss: # 过滤开关 enabled: true # 排除链接(多个用逗号分隔) excludes: /system/notice # 匹配链接 urlPatterns: /system/*,/monitor/*,/tool/*
前端打包
[root@test-02 webapps]# cd RuoYi-Vue/ruoyi-ui/ [root@test-02 ruoyi-ui]# ll total 20 -rw-r--r-- 1 root root 476 Aug 27 11:27 babel.config.js drwxr-xr-x 2 root root 61 Aug 27 11:27 bin drwxr-xr-x 2 root root 22 Aug 27 11:27 build -rw-r--r-- 1 root root 2126 Aug 27 11:27 package.json drwxr-xr-x 3 root root 73 Aug 27 11:27 public -rw-r--r-- 1 root root 538 Aug 27 11:27 README.md drwxr-xr-x 11 root root 203 Aug 27 11:27 src -rw-r--r-- 1 root root 4323 Aug 27 11:27 vue.config.js
安装npm工具
[root@test-02 ruoyi-ui]# yum install -y npm
安装依赖
[root@test-02 ruoyi-ui]# npm install --unsafe-perm --registry=https://registry.npm.taobao.org
开始打包
[root@test-02 ruoyi-ui]# npm run build:prod
把打包生成的dist目录复制到nginx配置的前端目录
[root@test-02 ruoyi-ui]# ll total 604 -rw-r--r-- 1 root root 476 Aug 27 11:27 babel.config.js drwxr-xr-x 2 root root 61 Aug 27 11:27 bin drwxr-xr-x 2 root root 22 Aug 27 11:27 build drwxr-xr-x 4 root root 87 Aug 27 11:49 dist drwxr-xr-x 910 root root 28672 Aug 27 11:48 node_modules -rw-r--r-- 1 root root 2126 Aug 27 11:27 package.json -rw-r--r-- 1 root root 550238 Aug 27 11:47 package-lock.json drwxr-xr-x 3 root root 73 Aug 27 11:27 public -rw-r--r-- 1 root root 538 Aug 27 11:27 README.md drwxr-xr-x 11 root root 203 Aug 27 11:27 src -rw-r--r-- 1 root root 4323 Aug 27 11:27 vue.config.js [root@test-02 ruoyi-ui]# ll dist/ total 24 -rw-r--r-- 1 root root 5663 Aug 27 11:49 favicon.ico drwxr-xr-x 2 root root 21 Aug 27 11:49 html -rw-r--r-- 1 root root 9880 Aug 27 11:49 index.html -rw-r--r-- 1 root root 26 Aug 27 11:49 robots.txt drwxr-xr-x 6 root root 51 Aug 27 11:49 static [root@test-02 ruoyi-ui]# cd /www/frontapps/ruoyi/ [root@test-02 ruoyi]# rm -rf * [root@test-02 ruoyi]# cp -r /www/webapps/RuoYi-Vue/ruoyi-ui/dist/* . [root@test-02 ruoyi]# ll total 24 -rw-r--r-- 1 root root 5663 Aug 27 13:40 favicon.ico drwxr-xr-x 2 root root 21 Aug 27 13:40 html -rw-r--r-- 1 root root 9880 Aug 27 13:40 index.html -rw-r--r-- 1 root root 26 Aug 27 13:40 robots.txt drwxr-xr-x 6 root root 51 Aug 27 13:40 static
后端打包
[root@test-02 ruoyi]# cd /www/webapps/RuoYi-Vue/ [root@test-02 RuoYi-Vue]# ll total 36 drwxr-xr-x 2 root root 57 Aug 27 11:27 bin drwxr-xr-x 2 root root 43 Aug 27 11:27 doc -rw-r--r-- 1 root root 1071 Aug 27 11:27 LICENSE -rw-r--r-- 1 root root 9720 Aug 27 11:27 pom.xml -rw-r--r-- 1 root root 5814 Aug 27 11:27 README.md drwxr-xr-x 3 root root 32 Aug 27 11:27 ruoyi-admin drwxr-xr-x 3 root root 32 Aug 27 11:27 ruoyi-common drwxr-xr-x 3 root root 32 Aug 27 11:27 ruoyi-framework drwxr-xr-x 3 root root 32 Aug 27 11:27 ruoyi-generator drwxr-xr-x 3 root root 32 Aug 27 11:27 ruoyi-quartz drwxr-xr-x 3 root root 32 Aug 27 11:27 ruoyi-system drwxr-xr-x 8 root root 4096 Aug 27 11:49 ruoyi-ui -rw-r--r-- 1 root root 1639 Aug 27 11:27 ry.bat -rw-r--r-- 1 root root 1724 Aug 27 11:27 ry.sh drwxr-xr-x 2 root root 47 Aug 27 11:27 sql
安装mvn
[root@test-02 RuoYi-Vue]# cd /opt/ [root@test-02 opt]# wget https://mirrors.bfsu.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz [root@test-02 opt]# tar zxf apache-maven-3.6.3-bin.tar.gz -C /usr/local/ [root@test-02 opt]# ln -s /usr/local/apache-maven-3.6.3/bin/mvn /usr/bin/
开始打jar包
[root@test-02 opt]# cd - /www/webapps/RuoYi-Vue [root@test-02 RuoYi-Vue]# mvn package Downloaded from public: http://maven.aliyun.com/nexus/content/groups/public/org/jdom/jdom2/2.0.6/jdom2-2.0.6.jar (305 kB at 167 kB/s) Downloaded from public: http://maven.aliyun.com/nexus/content/groups/public/com/google/guava/guava/19.0/guava-19.0.jar (2.3 MB at 1.2 MB/s) Downloaded from public: http://maven.aliyun.com/nexus/content/groups/public/org/ow2/asm/asm-util/7.0-beta/asm-util-7.0-beta.jar (81 kB at 42 kB/s) [INFO] Replacing main artifact with repackaged archive [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary for ruoyi 3.6.0: [INFO] [INFO] ruoyi .............................................. SUCCESS [ 0.002 s] [INFO] ruoyi-common ....................................... SUCCESS [01:37 min] [INFO] ruoyi-system ....................................... SUCCESS [ 0.446 s] [INFO] ruoyi-framework .................................... SUCCESS [ 5.998 s] [INFO] ruoyi-quartz ....................................... SUCCESS [ 0.945 s] [INFO] ruoyi-generator .................................... SUCCESS [ 0.855 s] [INFO] ruoyi-admin ........................................ SUCCESS [ 24.455 s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 02:15 min [INFO] Finished at: 2021-08-27T13:53:39+08:00 [INFO] ------------------------------------------------------------------------
启动后台
[root@test-02 RuoYi-Vue]# chmod +x ry.sh [root@test-02 RuoYi-Vue]# nohup java -jar ruoyi-admin/target/ruoyi-admin.jar &
nginx配置流量转发代理(最底下的一段“location”)
[root@test-02 RuoYi-Vue]# cd /usr/local/nginx/conf/ [root@test-02 conf]# cat nginx.conf worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #access_log logs/access.log main; sendfile on; keepalive_timeout 65; #gzip on; server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root /www/frontapps/ruoyi/; index index.html index.htm; } #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 html; } location /prod-api/ { proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://10.0.0.72:8080/; } } } [root@test-02 conf]# ../sbin/nginx -s reload