vue+java springboot项目上线部署

本文详细介绍如何在Linux服务器上部署Vue前端与SpringBoot后端应用,包括环境准备、文件复制、nginx配置及springboot运行方式,解决vue页面刷新访问问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

首先电脑上面准备好环境:

jdk、tomcat(springboot不需要)、nginx、mysql、redis

1.新建www/website文件夹,把vue 打包好的dist文件夹复制过去

2.springboot项目打包,首先双击clean,然后双击package

target下面生成打包好的jar文件

3.然后把打包好的jar文件复制到linux服务器上面

nginx配置(vue项目路径配置,接口反向代理配置)

try_files $uri $uri/ /index.html; 解决了,vue页面刷新时访问不到的问题!

server {
        listen       80;
        server_name  localhost;
 
        #charset koi8-r;
 
        #access_log  logs/host.access.log  main;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 
       location / {
            root   /www/website/;
            index  index.html index.htm;
            try_files $uri $uri/ /index.html;
        } 

       location /prod-api/ {
                proxy_pass http://localhost:8090/;
                proxy_pass_request_headers on;
                proxy_set_header Connection "";       
                client_max_body_size    30m;
                client_body_buffer_size 128k; 
                proxy_redirect off;
                proxy_connect_timeout   300;
                proxy_send_timeout      300;
                proxy_read_timeout      300;
                proxy_buffer_size       4k;
                proxy_buffers           4 32k;
                proxy_busy_buffers_size 64k;
                proxy_temp_file_write_size 64k;
                proxy_next_upstream http_502 http_504 error invalid_header; 
        }
    }

重启nginx

[root@iZ2ze5d84aus1odibe1uatZ opt]# cd /usr/local/nginx/sbin
[root@iZ2ze5d84aus1odibe1uatZ sbin]# ./nginx -s reload

springboot简单运行

[root@iZ2ze5d84aus1odibe1uatZ sbin]# cd /opt
[root@iZ2ze5d84aus1odibe1uatZ opt]# java -jar website.jar 

springboot后台运行

[root@iZ2ze5d84aus1odibe1uatZ sbin]# cd /opt
[root@iZ2ze5d84aus1odibe1uatZ opt]# nohup java -jar website.jar >/opt/website.log 2>&1 &


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

江湖行骗老中医

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

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

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

打赏作者

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

抵扣说明:

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

余额充值