部署手段可能有些粗糙,第一次弄也问了不少人,给个面子将就看。
linux后台部署项目
1、将项目放于git上,然后在服务器上拉取项目部署。
cd /
cd /opt/dev
git clone -b master http://litao:litao@106.14.138.71:3000/litao/bumblebee.git
cd /opt/dev/bumblebee //bumblebee项目名
source /etc/profile
mvn clean
mvn install
cd /opt/dev
netstat -lnp
kill -9
rm -rf pre-system-1.4.jar
cp /opt/dev/bumblebee/pre-system/target/pre-system-1.4.jar /opt/dev
nohup java -jar pre-system-1.4.jar & // pre-system启动类所在模块jar包
前台部署
1、使用 npm run build:prod打包后将dist打包文件放于和后台项目同一文件夹不同子目录中。方便查找/更换。
**************然后最重要的就是需要安装一个nginx并且部署项目。
listen 8090; //监听前端接口
server_name 106.14.138.71; //服务器ip或者域名
# root /opt/nginx/dist; #dist目录指向你本地的工作目录,相当重要(全局)
#后台服务配置,配置了这个location便可以通过http://域名/****-****/xxxx 访问
location /pre/ { //pre/通过这个可以找到proxy_pass所代理的后台
proxy_pass http://106.14.138.71:8091/;
# proxy_redirect off;
# proxy_cookie_path / /pre/;
}
location / {
root /opt/nginx/dist; //dist目录指向你本地的工作目录,相当重要(局部)
index index.html index.htm;
#try_files $uri $uri/ @router;
try_files $uri $uri/ /index.html?$args; //解决浏览器刷新资源报错
}