- 按需修改application-prod.yml,如需打开Swagger,那么需要将enabled设置为true。
- 打包jar包为app.jar
- 启动脚本 start.sh
nohup java -jar app.jar --spring.profiles.active=prod > nohup.out 2>&1 &
- 停止脚本 stop.sh
PID=$(ps -ef | grep app.jar | grep -v grep | awk '{ print $2 }') if [ -z "$PID" ] then echo Application is already stopped else echo kill -9 $PID kill -9 $PID fi
- 查看日志脚本 log.sh
tail -f nohup.out
- 配置nginx
server { listen 80; server_name 域名/当前服务器外网IP; location / { proxy_pass http://127.0.0.1:8000; #这里的端口记得改成项目对应的哦 proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Port $server_port; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } }