安装jdk
1 2
| cd /usr/java tar -zxvf jdk-8u281-linux-x64.tar.gz
|
1 2 3 4
| export JAVA_HOME=/usr/java/jdk1.8.0_281 export JRE_HOME=$JAVA_HOME/jre export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib export PATH=$PATH:$JAVA_HOME/bin
|
安装MySQL
- 下载MySQL官方的Yum Repository的配置文件
1
| wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
|
1
| yum -y install mysql57-community-release-el7-10.noarch.rpm
|
以上方法可能会出现下载速度很慢的问题,可以切换至阿里云的yum源
1
| mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
|
1
| wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
|
1 2
| yum clean all yum makecache
|
1
| yum -y install mysql57-community-release-el7-10.noarch.rpm
|
- 若发现报错,如:Failed to start mysqld.service: Unit not found.
则安装mariadb:
- 卸载mysql
1 2 3
| rpm -qa | grep mysql
yum -y remove mysql-community-common-5.7.33-1.el7.x86_64
|
- 安装mariadb(mysql的一个分支)
1 2 3
| yum install -y mariadb-server systemctl start mariadb.service systemctl enable mariadb.service
|
- 查看安装完成
1 2 3
| cd /usr/bin mysqladmin --version
|
1
| mysql_secure_installation
|
- 允许远程登录
1 2 3
| MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'XXXXX' WITH GRANT OPTION; MariaDB [(none)]> flush privileges;
|
- 接下来便可以使用Navicat等数据库工具进行远程连接
安装Redis
1 2
| cd /usr/local/redis wget http://download.redis.io/releases/redis-6.0.8.tar.gz
|
1
| tar -zxvf redis-6.0.8.tar.gz
|
- 由于Redis是由C语言编写的,所以需要安装gcc环境(使用gcc -v查看)
- 发现当前版本默认为4.8.5,而redis6.0只支持5.3版本以上的,所以我们需要升级gcc版本
1 2 3 4 5 6 7 8
| yum -y install centos-release-scl yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
scl enable devtoolset-9 bash echo "source /opt/rh/devtoolset-9/enable" >> /etc/profile
gcc -v
|
启动redis
方式一:前台启动(切换至 /usr/local/bin 目录下)
方式二:后台启动
- 先将 redis.conf 拷贝到当前目录下
1
| cp /usr/local/redis/redis-6.0.8/redis.conf /usr/local/bin
|
- 修改配置文件
1 2 3 4 5
| vim redis.conf
daemonize yes
requirepass xxxx
|
- 启动
1
| ./redis-server redis.conf
|
1 2 3 4 5 6 7
| redis-cli 127.0.0.1:6379> ping (error) NOAUTH Authentication required. 127.0.0.1:6379> auth "xxxx" OK 127.0.0.1:6379> ping PONG
|
- 开启远程连接(在 redis.conf 中注释掉以下内容 )
部署SpringBoot项目
1、将项目的jar包上传至Linux服务器上(目录可为 /home/webapp )
2、在jar包目录下编写启动脚本( vim start.sh )
脚本内容如下:
1 2
| nohup java -jar club-recruit-0.0.1-SNAPSHOT.jar &
|
3、修改脚本权限
4、以后使用如下命令启动即可
- 如果想要停止这个应用,可使用如下命令查看端口占用的进程号并结束进程
1 2
| netstat -anp | grep 端口号 kill sid
|