Skip to content

linux 部署 SpringBoot 项目

1 JDK-17 安装

1.1 在 ftp/java/linux/下载microsoft-jdk-17.0.8.1-linux-x64.tar.gz/root/

1.2 执行解压命令导入指定目录

bash
tar -zxvf /root/microsoft-jdk-17.0.8.1-linux-x64.tar.gz

2 MySQL 安装

2.1 在 ftp/java/linux/下载mysql-5.7.43-linux-glibc2.12-x86_64.tar.gz到指定目录,如/root/

2.2. 执行解压命令导入到指定目录

bash
tar -zxvf /root/mysql-5.7.43-linux-glibc2.12-x86_64.tar.gz

2.3 以管理员方式打开 cmd,进入 MySql 安装目录下的 bin 目录,执行命令

bash
#初始化mysql
./mysqld --initialize-insecure
#安装mysql
./mysqld -install
#启动mysql服务
net start mysql

2.4 登录 MySql 并设置:

bash
#登录账号
mysql -uroot -p

#设置密码
update mysql.user set authentication_string=password("123456.zxc") where user='root';

#设置远程访问
grant all privileges on *.* to 'root' @'%' identified by'123456.zxc';

#刷新
flush privileges;

2.6 开启linux 3306端口的防火墙允许外部访问;

bash
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload

3 Redis 安装

3.1 ftp/java/linux 下载redis-7.2.0.tar.gz

3.2 下一步执行安装操作

4 Nginx 安装

4.1 ftp/java/linux 下载nginx-1.24.0.tar.gz到指定目录,如/root/

4.2 解压文件nginx-1.24.0.tar.gz

bash
tar -zxvf /root/nginx-1.24.0.tar.gz

4.3 进入解压后的目录,执行命令

bash
./configure --prefix=/usr/local/nginx
make
make install

4.4 修改 nginx.conf

bash
#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

http {
  include       mime.types;
  default_type  application/octet-stream;

  log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" '
                    '"$http_user_agent" "$http_x_forwarded_for"';

  # 优化静态资源的访问性能
  sendfile        on;

  # 启用 gzip 压缩,注意需要在安装 nginx 时启用 gzip 模块
  gzip  on;
  gzip_buffers 16 8k;
  gzip_comp_level 6;
  gzip_http_version 1.1;
  gzip_min_length 256;
  gzip_proxied any;
  gzip_vary on;
  gzip_types
      text/xml application/xml application/atom+xml application/rss+xml application/xhtml+xml image/svg+xml
      text/javascript application/javascript application/x-javascript
      text/x-json application/json application/x-web-app-manifest+json
      text/css text/plain text/x-component
      font/opentype application/x-font-ttf application/vnd.ms-fontobject
      image/x-icon;
  gzip_disable "MSIE [1-6]\.";

  server {
    #前端项目端口号
    listen 3000;
    server_name  localhost;
    location / {
        #前端文件根目录
        root   html/web;
        index  index.html index.htm;
        try_files $uri $uri/ /index.html;
    }
  }
}

5 Minio 安装

5.1 ftp/java/linux 下载minio到指定目录,如root/

5.2 执行命令

bash
nohup ./minio server /root/data/jpwise-resources > /root/data/jpwise-resources/minio.log 2>&1 &