JeecgBoot部署(Nginx+Tomcat)

  1. 环境搭建
    JeecgBoot搭建Linux安装NginxLinux安装JDK8Linux安装MySql8Linux安装RedisLinux安装Tomcat9
  2. 前端打包
    1.进入目录:cd D:\win11\git_data\jeecg_3.4.4\jeecgboot-vue3
    
    2.安装依赖:pnpm install-->node_modules
    
    3.打包编译:pnpm run build-->dist

  3. 前端部署

    1.将D:\win11\git_data\jeecg_3.4.4\jeecgboot-vue3\dist下所有文件复制到/opt/nginx/nginx_install/html
    
    2.编辑:/opt/nginx/nginx_install/conf/nginx.conf
    server {
    	listen       8181;
    	server_name  192.168.1.97;
    	#前端打的dist资源存放目录
    	root		   /opt/nginx/nginx_install/html;
    	
    	location / {
    		# 用于配合 browserHistory使用
    		try_files $uri $uri/ /index.html;
    	}
    }
    
    3.Nginx常用命令(重载配置需要在启动状态下执行)
    启动/查看/关闭/重载-->nginx/ps -ef | grep -i nginx/nginx -s stop/nginx -s reload
    
    4.放开端口:firewall-cmd --zone=public --add-port=8181/tcp --permanent && firewall-cmd --reload
    
    5.前端访问:192.168.1.97:8181
    用户名:admin 密码:123456

  4. 后端打包

    1.编辑:jeecg-boot\jeecg-module-system\jeecg-system-start\pom.xml
    <artifactId>jeecg-system-start</artifactId>
    <packaging>war</packaging>
    <!--    <build>-->
    <!--        <plugins>-->
    <!--            <plugin>-->
    <!--                <groupId>org.springframework.boot</groupId>-->
    <!--                <artifactId>spring-boot-maven-plugin</artifactId>-->
    <!--            </plugin>-->
    <!--        </plugins>-->
    <!--    </build>-->
     
    2.编辑:jeecg-boot\jeecg-boot-base-core\src\main\java\org\jeecg\config\WebSocketConfig.java
    //    @Bean
    //    public ServerEndpointExporter serverEndpointExporter() {
    //        return new ServerEndpointExporter();
    //    }
     
    3.编辑:jeecg-boot\jeecg-module-system\jeecg-system-start\src\main\resources\application-prod.yml
    datasource:
      master:
        url: jdbc:mysql://192.168.1.97:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
        username: mysql
        password: 123456
        driver-class-name: com.mysql.cj.jdbc.Driver
     
      #redis 配置
      redis:
        database: 0
        host: 192.168.1.97
        port: 6379
        password: '123456'
    
      #swagger
      knife4j:
        #开启增强配置
        enable: true
        #开启生产环境屏蔽
        production: false
        basic:
          enable: true
          username: jeecg
          password: jeecg1314
    
    注意:MySQL创建用户(用户名:mysql 密码:123456),创建数据库(库名:jeecg-boot 脚本:jeecg-boot\db\jeecgboot-mysql-5.7.sql),Redis设置的密码为123456
     
    4.IDEA切换生产模式配置文件(prod)-->parent项目clean、install、package-->jeecg-boot\jeecg-module-system\jeecg-system-start\target\jeecg-system-start-3.4.4.war

  5. 后端部署

    1.编辑:/opt/tomcat/apache-tomcat-9.0.70/conf/server.xml
    <Connector port="8282" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8"/>
    
    2.将jeecg-system-start-3.4.4.war放入/opt/tomcat/apache-tomcat-9.0.70/webapps-->重命名为jeecg-boot.war
     
    3.Tomcat常用命令
    启动/关闭/查看-->startup.sh/shutdown.sh/ps -ef | grep -i tomcat
     
    4.放开端口:firewall-cmd --zone=public --add-port=8282/tcp --permanent && firewall-cmd --reload
    
    5.后端访问:http://192.168.1.97:8282/jeecg-boot
    用户名:jeecg 密码:jeecg1314

  6. Nginx动静分离

    1.JeecgBoot为典型前后端分离项目,Nginx作为静态服务器部署前端项目(处理静态资源请求),Tomcat作为动态服务器部署后端项目
    (处理动态资源请求),同时Nginx作为反向代理服务器,接收到静态资源请求后交由Nginx处理,接收到动态资源请求后交由Tomcat处理
    
    2.验证码请求http://192.168.1.97:8181/jeecgboot/sys/randomImage/xxxx为动态请求,反向代理服务器Nginx
    接收到请求后需要将请求转给Tomcat处理,转到http://192.168.1.97:8282/jeecg-boot/sys/randomImage/xxxx
    
    3.实现验证码请求转发,Nginx需要将http://192.168.1.97:8181/jeecgboot/开头的请求转到
    http://192.168.1.97:8282/jeecg-boot/,编辑/opt/nginx/nginx_install/conf/nginx.conf
    server {
    	listen       8181;
    	server_name  192.168.1.97;
    	#前端打的dist资源存放目录
    	root		   /opt/nginx/nginx_install/html;
    	
    	location / {
    		# 用于配合 browserHistory使用
    		try_files $uri $uri/ /index.html;
    	}
    	
    	location /jeecgboot/ {
    		# 反向代理,将/jeecgboot/匹配的请求路径转发到指定服务器
    		proxy_pass http://192.168.1.97:8282/jeecg-boot/;
    	}
    }
    
    4.前端访问:192.168.1.97:8181-->验证码成功加载


  7. Nginx虚拟主机

    1.目前为止,项目通过IP直接访问,接下来通过Nginx虚拟主机模拟域名访问
    
    2.编辑:C:\Windows\System32\drivers\etc\hosts
    192.168.1.97 my.jeecg.com
    
    3.编辑/opt/nginx/nginx_install/conf/nginx.conf
    server {
    	listen       80;
    	server_name  my.jeecg.com;
    	#前端打的dist资源存放目录
    	root		   /opt/nginx/nginx_install/html;
    	
    	location / {
    		# 用于配合 browserHistory使用
    		try_files $uri $uri/ /index.html;
    	}
    	
    	location /jeecgboot/ {
    		# 反向代理,将/jeecgboot/匹配的请求路径转发到指定服务器
    		proxy_pass http://192.168.1.97:8282/jeecg-boot/;
    	}
    }
    
    4.放开端口:firewall-cmd --zone=public --add-port=80/tcp --permanent && firewall-cmd --reload
    
    5.项目访问:my.jeecg.com

  • 10
    点赞
  • 32
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 6
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

童心同萌

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值