将前后端分离项目部署步骤

将前后端分离项目部署步骤

0.Filezilla安装和使用

如果一直连不上可能是服务器21端口没有开 filezilla上传文件,使用FileZilla上传文件的方法 _ 【IIS7站长之家】

1. JDK安装配置

64版本:jdk1.8.0_18164.msi 配置 : (4条消息) Java基础(一):Windows下JDK的安装和配置_Xiaofei_Mo的博客-CSDN博客_jdk的安装与配置

2. node安装配置

64版本:node-v14.17.6-x64.msi 配置:Node.js安装详细步骤教程(Windows版) - 码探长 - 博客园 (cnblogs.com)

3. mysql安装配置

64版本:mysql-5.7.19-winx64 配置:Windows 安装 MySql-5.7.19 笔记 - 面包不是超人 - 博客园 (cnblogs.com)注意这里的密码修改,直接复制可能会出错,寻找其他方法修改密码

4.nginx安装配置

64版本:nginx-1.20.2解压即可 关键是配置文件 conf 在进入有nginx.exe 终端打开启动即可,直接双击会闪退


#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"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       9528;
        server_name  localhost;
        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }	
     #配置没有用,不知道为什么 直接在前端吧baseUrl修改成服务器地址101.35.226.248
	location /back/{

	        proxy_pass http://101.35.226.248:9095;
	}

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

     
}

4. springboot项目的打包步骤

加入maven打包依赖 ,先clean 后package 在项目的target生成 项目名.jar 拷贝到服务器 并在cd到拷贝的文件夹下运行Java -jar 项目名.jar

           <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <includeSystemScope>true</includeSystemScope>
                </configuration>
            </plugin>

5.vue项目部署

查看index.js 的配置 运行 npm run build:prod 生成dist文件,可以先在本地测试下生成service.js 然后 在当前文件夹下node service

var express = require('express');
 var app = express();
 const hostname = '127.0.0.1';
 const port = 9528;
 app.use(express.static('./'));
 app.listen(port,hostname, () => {
  console.log(` running ......`);
 });

拷贝到nginx文件夹下的html文件夹 在当前文件下运行命令nginx.exe 如果修改了配置文件conf需要命令nginx -s reload

主要参考:(4条消息) 将springboot项目和vue项目部署到windows 2016 server(服务器)_shallow丶十三的博客-CSDN博客_部署vue项目到windows

打赏一个呗

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦