SpringBoot项目部署
一.安装JDK
--yum list列出源上的所有软件包。grep jdk把包含jdk关键字的结果保留下来。
yum list|grep jdk
--安装JDK
yum install java-1.8.0-openjdk-devel.x86_64
--验证是否安装成功
javac
二、安装Tomcat
1.下载压缩包
--列出tomcat包
yum list | grep tomcat

选择版本

用的是8版本的,上面的版本较低,程序中有的可能会运行不起来,因此将以前使用过的压缩包拖到linux上去即可。tomcat是java写的,跨平台程序。
三、安装MySql
安装 mariadb 服务
# yum install -y mariadb-server
安装 mariadb 命令行客户端
# yum install -y mariadb
安装 mariadb C library
# yum install -y mariadb-libs
安装 mariadb 开发包
# yum install -y mariadb-devel
2.启动数据库
启动服务
# systemctl start mariadb
设置服务开启自启动
# systemctl enable mariadb
查看服务状态
# systemctl status mariadb
3.测试连接
使用命令行客户端尝试连接
# mysql -uroot
可能的输出为
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
创建数据库时为了支持中文,统一使用 utf8mb4 字符集
create database demo_db charset utf8mb4;
通过刚才的操作,就已经完成了jdk,,tomcat,mysql的安装。准备工作已经就绪了。
接下来就需要把写的web给部署到云服务器上去。
四、安装Redis包(需要用到Redis)
redis 安装到 linux 服务器
yum -y install redis
以后台运行方式启动 redis:
redis-server /etc/redis.conf &
启动 redis 客户端
redis-cli

redis端口号:6379
存放键值

设置远程连接(Redis)
redis可视化客户(Another Redis Desktop Manager)端连接
1.redis 配置文件下载到本地:redis 配置文件是 linux 下的 /etc/redis.conf ;
2.将 redis.conf 中的 “bind 127.0.0.1”注释掉;
3.将 redis.conf 中的“protected-mode yes” 改为“protected-mode no”;
4.将修改后的 redis.conf 上传至 liunx 下的 /etc 目录;
5.使用命令“redis-cli shutdown”先关闭 redis 服务,再使用“redis-server /etc/redis.conf &”启动 redis 服务
五.打包SpringBoot项目


如果打包出错发生以上错误

取消国内源配置
六.生成的jar包上传到服务器
直接将jar包拖入linux中
启动jar包
nohup java -jar 包名.jar &
查询springboot进程
ps -ef|grep java

将 Spring Boot 的进程结束掉
kill -9 进程ID
3、导入数据库数据
-- 创建⽂章表
drop table if exists articleinfo;
create table articleinfo(
id int primary key auto_increment,
title varchar(100) not null,
content text not null,
updatetime TIMESTAMP not NULL DEFAULT CURRENT_TIMESTAMP,
createtime datetime NOT NULL DEFAULT '2023-05-10 00:00:00',
uid int not null,
rcount int not null default 1,
`state` int default 1
)default charset 'utf8mb4';
Redis
项目中配置有Redis,也要在linux中安装redis包