记录项目部署问题,以防自己下次忘记

  • :将vue打包后放在springboot项目的resource下的static文件夹下,跟springboot项目一起被打成jar包

cd到vue项目目录下,执行npm run bulid:prod命令watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAbHlhdGY=,size_20,color_FFFFFF,t_70,g_se,x_16

然后会在项目根目录下生成一个dist目录,里面就是打包好的,然后放到后端resource下的static目录下(没有的话新建一个),然后后端正常打包部署。

  • ngnix去做代理,前后端分开部署

服务器是Linux,cd到nginx目录,修改配置文件,将打包好的dist放到root设置的路径:

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;
		charset utf-8;

		location / {
            root   /home/ruoyi/projects/ruoyi-ui;
			try_files $uri $uri/ /index.html;
            index  index.html index.htm;
        }
		
		location /prod-api/ {
			proxy_set_header Host $http_host;
			proxy_set_header X-Real-IP $remote_addr;
			proxy_set_header REMOTE-HOST $remote_addr;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_pass http://localhost:8080/;
		}

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

记得开放端口

Logo

前往低代码交流专区

更多推荐