- 前端
npm run build 打包Vue工程,切记其中axios请求改为服务器端口。 - 后端
打包Springboot工程为jar包,IDEA整合,生成文件夹格式(里面全是jar包),将整个文件夹或者你生成的是一个总的jar包,放入服务器自定位置。
然后运行:
nohup java -jar 你得jar包名字.jar >temp.txt &
这命令的意思就是后台挂起jar包,并将日志写入temp.txt文件中,当然你爱写给谁就写给谁
- 连接,找到nginx.conf /etc/nginx/nginx.conf
1、nginx -t 查找配置文件路径
2、进入路径修改配置server,写好dist文件路径,以及后端端口号;实例(在http{}中):
server {
listen 8080; //端口自定,springboot封装tomcat,一般为8080
server_name localhost;
location / {
root /home/booksys/dist; //存放vue的dist包的路径
index index.html index.htm; //固定写法
}
//后端访问地址
location /manager/ {
proxy_pass http://你服务器的ip:你所制定的前后端跨域端口/;
}
}
- 完事记得重启下nginx哦
systemctl start nginx.service
systemctl stop nginx.service
systemctl reload nginx.service
systemctl status nginx.service