SpringBoot + Vue + nginx项目部署

1.nginx安装参照https://blog.csdn.net/qq_22027637/article/details/81776092

2.将springboot项目打包上传到服务器,开启服务

启动springboot项目可以用二种方式:(1)nohup java -jar demo.jar &

                                                            (2)nohup java -jar demo.jar & > log.file 2>&1 &

3.vue项目打包上传到服务器:  npm run build

打包后会生成静态页面,在项目根路径的dist文件夹下面,将该文件夹移到服务器的某个目录下,我这里是/root/ncp

4.修改nginx配置文件,配置文件默认是/usr/local/nginx/conf/nginx.conf

location / {     
        root /root/vueproject/dist;    //vue项目部署路径      
        try_files $uri $uri/ /index.html last;    //解决页面刷新404问题      
        index  index.html index.htm;
}

另外在nginx配置文件nginx.conf头部加上user root;

重启nginx,进入/usr/local/nginx/sbin

./nginx -s reload

访问http://ip:nginx端口号,例如http:127.0.0.1/9000,即可访问页面,至此vue项目前台就部署完成了

再次修改nginx配置文件nginx.conf,在nginx.conf中增加


location /manager/ {
     proxy_pass http://127.0.0.1:9006/;    //springboot项目端口
}

重启nginx

访问http://ip:nginx端口号,即可实现与后台交互

转载自:https://blog.csdn.net/liangsu1314/article/details/82893302

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值