shell部署nginx+tomcat代理负载用supervisor守护批量前台启动

vim aa.sh

#!/bin/bash
systemctl stop firewalld
setenforce 0
wget http://nginx.org/download/nginx-1.16.1.tar.gz
yum -y install gcc gcc-c++ zlib-devel pcre-devel
tar zxf nginx-1.16.1.tar.gz
cd nginx-1.16.1 && ./configure && make && make install
shulian=`cat /usr/local/nginx/conf/nginx.conf|grep 'server 192.168.11.135:8081;'|wc -l`
if [ $shulian -ne 1 ];then #判断是否有该配置
sed -i  '/#gzip  on;/aupstream wg{' /usr/local/nginx/conf/nginx.conf   #在gzip  on;下一行追加upstream wg{
sed -i  '/upstream wg{/aserver 192.168.11.135:8080;' /usr/local/nginx/conf/nginx.conf   #在upstream wg{下一行追加server 192.168.11.135:8080;
sed -i  '/server 192.168.11.135:8080;/aserver 192.168.11.135:8081;' /usr/local/nginx/conf/nginx.conf  #在server 192.168.11.135:8080;下一行追加server 192.168.11.135:8081;
sed -i  '/server 192.168.11.135:8081/a\}' /usr/local/nginx/conf/nginx.conf  #在server 192.168.11.135:8081;下一行追加}
sed -i  's/index.htm;$/index.jsp;/' /usr/local/nginx/conf/nginx.conf  #把以index.htm;结尾换成index.jsp;
sed -i  '/404.html;/alocation ~ \\.jsp$ {' /usr/local/nginx/conf/nginx.conf  #在404.html;下一行追加location ~ \.jsp$ {
sed -i  '/location ~ \\.jsp$ {/aproxy_pass   http://wg;' /usr/local/nginx/conf/nginx.conf #在location ~ \.jsp$ {下一行追加proxy_pass   http://wg;
sed -i  '/proxy_pass   http:\/\/wg;/a\}' /usr/local/nginx/conf/nginx.conf  #在proxy_pass   http://wg;下一行追加}
fi
cd /root && rpm -ivh jdk-8u20-linux-x64.rpm     #自己拉jdk包到\root
cishu=`cat /etc/profile|grep 'JAVA_HOME'|wc -l`
if [ $cishu -ne 4 ];then   #判断是否有该配置
echo -e 'export JAVA_HOME=/usr/java/jdk1.8.0_20
export JAVA_BIN=/usr/java/jdk1.8.0_20/bin
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH' >>/etc/profile
fi
source /etc/profile
wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-7/v7.0.96/bin/apache-tomcat-7.0.96.tar.gz
tar zxf apache-tomcat-7.0.96.tar.gz
cp -r apache-tomcat-7.0.96 /opt/tomcat
cp -r apache-tomcat-7.0.96 /opt/tomcat1
sed -i 's/8005/8006/' /opt/tomcat1/conf/server.xml #把所有8005换成8006
sed -i 's/8009/8010/' /opt/tomcat1/conf/server.xml #把所有8009换成8010
sed -i 's/8080/8081/' /opt/tomcat1/conf/server.xml #把所有8080换成8081
yum -y install epel-release
yum -y install supervisor
echo '[program:nginx]
command=/usr/local/nginx/sbin/nginx -g "daemon off;"
[program:tomcat]
command=/opt/tomcat/bin/catalina.sh run
[program:tomcat1]
command=/opt/tomcat1/bin/catalina.sh run' >/etc/supervisord.d/nginx.ini
systemctl restart supervisord
sed -i 's/Congratulations!/111111111111/' /opt/tomcat1/webapps/ROOT/index.jsp

测试后面跟着index.jsp结果
在这里插入图片描述
在这里插入图片描述

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值