[封面图]

封面图

前提

  • Nginx
  • Redis

Nginx

Centos7 系统

1
2
3
4
5
6
7
yum -y install gcc gcc- c++ pcre-devel openssl-devel wget
wget http://nginx.org/download/nginx-1.12.2.tar.gz
tar xf nginx-1.12.2.tar.gz
cd nginx-1.12.2
./configure --prefix=/usr/local/nginx
make && make install
ln -sv /usr/local/nginx/sbin/nginx /usr/bin/nginx

【验证】访问:http://ip

Redis

前端

执行npm run build

打包后的文件在dist目录下,后面需要将打包后的文件放到Nginx

后端

修改MySQL的ip、用户名和密码后,使用maven打包,target目录下生成xxx.jar

后面上传到服务器后执行java -jar xxx.jar即可

搭建环境

配置Redis

上传后端代码

将前端打包生成的dist目录上传到/usr/local/nginx/html/dist

将后端打包生成的xxx.jar文件上传到/usr/service/xxx.jar

Nginx配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
server {
listen 80; # http
server_name ye.wudiguang.top; # 域名

location / {
alias /usr/local/nginx/html/dist/;
index index.html;
try_files $uri $uri/ /index.html;
}

location /prod-api/ {
rewrite ^.+prod-api/?(.*)$ /$1 break;
include uwsgi_params;
proxy_pass http://localhost:8080; #后端服务地址
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}