一、介绍
RuoYi-Vue 是一个 Java EE 企业级快速开发平台,基于SpringBoot、Spring Security、Jwt、Vue的前后端分离的后台管理系统,内置模块如:部门管理、角色用户、菜单及按钮授权、数据权限、系统参数、日志管理、代码生成等。在线定时任务配置;支持集群,支持多数据源,支持分布式事务。
二、部署环境
| 主机 | IP |
| 前端Nginx | 192.168.168.101 |
| 后端Java | 192.168.168.102 |
| 数据库DBserver | 192.168.168.103 |
三、服务器部署
数据库DBserver的安装
(1)安装数据库:
yum -y install mysql-community-server
yum -y install redis
vi /etc/redis.conf
bind 0.0.0.0
daemonize yes
————————————————end——————————————————
systemctl enable --now redis
systemctl enable --now mysqld
(2)查询mysql默认密码:
grep -i "password" /var/log/mysqld.log
(3)配置mysql的安全设置:
mysql_secure_installation
(4)设置mysql的安全级别:
mysql -uroot -p -e "set global validate_password.policy=LOW;"
(5)设置mysql的密码长度要求:
mysql -uroot -p -e "set global validate_password.length=4;"
(6)创建远程登录账号:
mysql -uroot -p -e "create user 'root'@'%' IDENTIFIED BY '1234';"
mysql -uroot -p -e "GRANT all privileges ON *.* TO 'root'@'%';"
mysql -uroot -p -e "flush privileges;"
后端Java服务器的安装:
(1)安装后端服务器环境:
yum -y install jdk1.8 nodejs maven npm
(2)下载RuoYi源代码:
git clone https://gitee.com/y_project/RuoYi-Vue.git
(3)从ruoyi后端代码sql目录中导入数据库:
mysql -h192.168.168.103 -uroot -p -e "create database ruoyi character set utf8 collate utf8_general_ci;"
mysql -h192.168.168.103 -uroot -p ruoyi < quartz.sql
mysql -h192.168.168.103 -uroot -p ruoyi < ry_20240629.sql
(4)前端代码打包:
cd RuoYi-Vue/ruoyi-ui
[root@Java ruoyi-ui]# npm install --registry=https://registry.npmmirror.com
[root@Java ruoyi-ui]# npm run build:prod
(5)修改后端配置文件:
cd ..
[root@java RuoYi-Vue]# vi ruoyi-admin/src/main/resources/application.yml
……
redis:
# 地址
host: 192.168.168.103
# 端口,默认为6379
port: 6379
# 数据库索引
database: 0
# 密码
password:
……
[root@java RuoYi-Vue]# vi ruoyi-admin/src/main/resources/application-druid.yml
driverClassName: com.mysql.cj.jdbc.Driver
druid:
# 主库数据源
master:
url: jdbc:mysql://192.168.168.103:3306/ruoyi?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: 123456
……
(6)后端项目打包:
[root@Java RuoYi-Vue]# mvn package
(7)后端项目上线
[root@java RuoYi-Vue]# java -jar -server -Xmx1024m -Xms1024m ruoyi-admin/target/ruoyi-admin.jar
前端Nginx服务器的部署:
yum -y install nginx
(1)添加配置文件
vi /etc/nginx/conf.d/ruoyi.conf
upstream rs {
server 192.168.168.102:8080;
}
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
location /prod-api/ {
proxy_pass http://rs/;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
(2)把打包好的前端代码拷贝到nginx:
scp -r [email protected]:/root/RuoYi-Vue/ruoyi-ui/dist/* /usr/share/nginx/html/
(3)开启nginx
systemctl enable --now nginx
四、测试
使用浏览器访问nginx的所在IP

默认用户密码:admin/admin123

Leave a Reply