Linux发布Spring Boot项目


Linux发布Spring Boot项目

一、CentOS7虚拟机环境

  • CentOS7
  • JDK 1.8.0_331
  • MySQL 8.0.18

1、清理后打包项目

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

2、上传jar到Linux中

[root@mycentos7 ~]# ll
总用量 30276
-rw-r--r--. 1 root root 30998612 93 13:36 day63_springboot_ssmp-0.0.1-SNAPSHOT.jar

3、查看IP

// 查看IP为:192.168.8.136
[root@mycentos7 ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.8.136  netmask 255.255.255.0  broadcast 192.168.8.255
        inet6 fe80::8962:9acc:7179:e2f2  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:ca:f5:b2  txqueuelen 1000  (Ethernet)
        RX packets 1671096  bytes 2372855953 (2.2 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 236520  bytes 31727598 (30.2 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 200  bytes 39477 (38.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 200  bytes 39477 (38.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:7d:f7:90  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

4、关闭防火墙

// 关闭防火墙
[root@mycentos7 jar]# systemctl stop firewalld

5、运行jar包

[root@mycentos7 jar]# java -jar day63_springboot_ssmp-0.0.1-SNAPSHOT.jar 

6、浏览器访问

  • http://192.168.8.136/pages/books.html
    在这里插入图片描述

二、真实服务器环境

4、需要开启端口

  • 这里开启的端口是 9000
// 查看防火墙状态
[root@VM-20-13-centos bin]# systemctl status firewalld
// 开启9000端口
[root@VM-20-13-centos sgz]# firewall-cmd --zone=public --add-port=9000/tcp --permanent
success	
// 重启防火墙
[root@VM-20-13-centos sgz]# systemctl restart firewalld.service	
// 查看所有的开启端口
[root@VM-20-13-centos sgz]# firewall-cmd --list-ports
20/tcp 21/tcp 22/tcp 80/tcp 888/tcp 8888/tcp 9000/tcp 39000-40000/tcp
// 查看全部信息
[root@VM-20-13-centos bin]# firewall-cmd --list-all

三、后台运行

  • nohup java -jar xxx.jar > server.log 2>&1 &
[root@mycentos7 ~]# nohup java -jar day63_springboot_ssmp-0.0.1-SNAPSHOT.jar > server.log 2>&1 &
[1] 3764
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值