jdk、maven、node、mysql、redis准备
mysql准备
#安装mysql
apt install mysql-server
修改mysql配置
vim /etc/mysql/mysql.conf.d/mysqld.cnf
#注释这两条
#bind-address = x.x.x.x
#mysqlx-bind-address = x.x.x.x
启动mysql
systemctl start mysql.service
mysql创建库、用户及授权
create database ry;
create user 'dongzhi'@'%' identified with mysql_native_password by '123456';
grant all privileges on *.* to 'dongzhi'@'%';
flush privileges;
redis准备
#安装redis
apt install redis-server
修改redis配置
vim /etc/redis/redis.conf
#修改以下配置
bind 0.0.0.0
启动redis
systemctl start redis-server.service
jdk准备
cd /opt
tar xf jdk-8u212-linux-x64.tar.gz
ln -s jdk1.8.0_212 jdk
maven准备
cd /opt
tar xf apache-maven-3.8.8-bin.tar.gz
ln -s apache-maven-3.8.8 maven
maven配置
在</mirrors>标签中配置
vim maven/conf/settings.xml
...
<mirror><id>aliyunmaven</id><mirrorOf>*</mirrorOf><name>阿里云公共仓库</name><url>https://maven.aliyun.com/repository/public</url>
</mirror>
...
node准备
cd /opt
tar xf node-v16.19.0-linux-x64.tar.gz
ln -s node-v16.19.0-linux-x64 node
配置环境变量
vim /etc/profile
export JAVA_HOME=/opt/jdk
export MAVEN_HOME=/opt/maven
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
export PATH="$JAVA_HOME/bin:$MAVEN_HOME/bin:/opt/node/bin:$PATH"
加载环境变量配置文件
source /etc/profile
若依部署
下载若依源码
git clone https://gitee.com/y_project/RuoYi-Vue.git
cd RuoYi-Vue-master
导入以下sql
ls sql/*
sql/quartz.sql sql/ry_20240629.sql
修改若依后端配置文件
vim ruoyi-admin/src/main/resources/application-druid.yml
...
# 数据源配置
spring:datasource:type: com.alibaba.druid.pool.DruidDataSourcedriverClassName: com.mysql.cj.jdbc.Driverdruid:# 主库数据源master:url: jdbc:mysql://192.168.0.129:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8username: dongzhipassword: 123456
...
vim ruoyi-admin/src/main/resources/application.yml
...# redis 配置redis:# 地址host: 192.168.0.129# 端口,默认为6379port: 6379# 数据库索引database: 0# 密码password:
...
后端打包
#打包
mvn clean package -Dmaven.test.skip=true
#启动
cd ruoyi-admin/target/
java -jar ruoyi-admin.jar
前端打包
cd ruoyi-ui
#安装依赖
npm install --registry=https://registry.npmmirror.com
# 打包
npm run build:prod
nginx准备
安装nginx
apt install nginx
配置nginx
cd /etc/nginx/conf.d
vim ruoyi.conf
server {listen 80;server_name localhost;charset utf-8;location / {root /opt/RuoYi-Vue-master/ruoyi-ui/dist;try_files $uri $uri/ /index.html;index index.html index.htm;}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://localhost:8080/;}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}}
启动nginx
systemctl start nginx.service
部署成功结果