nginx部署vue+springboot
vue项目打包,如下npm run build打包后会生成静态页面,在项目根路径的dist文件夹下面将该文件夹移到服务器的某个目录下,我这里是/root/vueproject修改nginx配置文件,我这里是/usr/local/nginx/conf/nginx.conflocation / {root /root/vueproject/dist;//v...
·
- vue项目打包,如下
打包后会生成静态页面,在项目根路径的dist文件夹下面npm run build
- 将该文件夹移到服务器的某个目录下,我这里是/root/vueproject
- 修改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;
user root;
重启nginx,进入/usr/local/nginx/sbin
./nginx -s reload
访问http://ip:nginx端口号,例如http:127.0.0.1/9000,即可访问页面,至此vue项目前台就部署完成了,接下来就是部署vue项目java后端
-
我这里使用后端使用的是springboot,所以需要先将springboot项目打包,maven install
-
部署springboot项目,启动
java -jar 项目打包名称
上面这种方式关闭终端窗口或者ctrl+c退出后项目就停止了,为了让项目在后台运行,换种方式启动
nohup java -jar 项目打包名称 &
-
修改nginx配置文件nginx.conf
location /manager/ { proxy_pass http://127.0.0.1:9006/; }
重启nginx,进入/usr/local/nginx/sbin
./nginx -s reload
访问http:127.0.0.1/9000,即可实现与后台交互
更多推荐
已为社区贡献1条内容
所有评论(0)