1. 服务器
服务器选择Linux的CentOS7的版本
2. 宝塔Linux面板
2.1 百度搜索宝塔

2.2 进去之后点击立即免费安装

2.3 选择Linux在线安装,输入服务器信息进行安装(也可以选择其他方式)
安装完成之后会弹一个宝塔的应用面板,并附带有登录名称和密码,这个要自己记下来的。
然后我们在浏览器打开这个面板,输入刚刚的名称和密码就能登录到该管理界面了。


3. 搭建Linux项目运行环境
3.1 创建MySql数据库,保存用户名和密码,上传sql文件并导入


3.2 安装配置Redis
比如我的项目中用到了Redis,那就对应的再安装一个Redis就行了呀,然后进行配置就可以。
我的项目中因为配置文件中没有设置Redis的密码和IP什么的,所以项目默认就会采用本机的Redis,其他的需要配置就配置没有配置就用默认的配置就可以。
4. 部署Java项目
4.1 创建文件夹,上传jar包

4.2 添加Java项目

4.2 启动后端服务

4.2 添加Java项目
5. 部署Vue项目
5.1 上传dist压缩包,并解压

5.2 第一种方式:通过nginx访问
server {
listen 80;
server_name localhost;
charset utf-8;
location / {
root /www/project/dist;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
location /accounting {
alias /www/project/dist1;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
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:8081/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
5.2 第二种方式:选择网站 -> PHP项目 -> 添加站点
-
域名填写公网ip(可以加上端口号)
-
根目录选择解压的dist
-
PHP版本选择纯静态

5.3 修改配置文件

访问前端页面刷新出现404,添加下面代码
location / {
try_files $uri $uri/ /index.html;
}
添加接口路径
location /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:8081/;
}