1:在nginx配置增加:(我这里一个是后台管理项目,一个是APP接口项目)
server {
listen 80;
server_name xxx.xxx.cn;#这里是域名
access_log logs/book.log;
error_log logs/book.error;
#将/ce-admin请求转发给http://127.0.0.1:9196/ce-admin处理
location /ce-admin {
proxy_pass http://127.0.0.1:9196/ce-admin; #这里的端口记得改成项目对应的哦
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
}
location /ce-rest {
proxy_pass http://127.0.0.1:8098/ce-rest; #这里的端口记得改成项目对应的哦
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
}
}
2: springboot项目得在配置文件中配置
server:
port: 9196
servlet:
context-path: /ce-admin
3:快速启动项目 脚本(注意修改JAVA_HOME、port、JarName) 保存命名为xx.sh
export JAVA_HOME=/usr/local/java/jdk1.8.0_162
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
Port=9196
JarName=ce-admin.jar
LogsPatch=./logs_$Port
ID=`ps -ef | grep $Port | grep -v "grep" | awk '{print $2}'`
echo $ID
echo "---------------"
for id in $ID
do
kill -s 9 $id
echo "killed $id"
done
echo "---------------"
rm -rf $LogsPatch
mkdir $LogsPatch
export LANG=zh_CN.UTF-8
set -m
nohup java -jar -Dlogging.path=$LogsPatch $JarName>$LogsPatch/catlina.out 2>&1 &
tail -f $LogsPatch/catlina.out
4:利用宝塔创建站点,访问不成功。需要在配置文件增加
location / {
root /www/wwwroot/xxx.xxx.cn/; #站点路径
index index.html index.htm; #默认的首页
}