一键部署Tomcat环境-v1
#!/bin/bash #2020-03-15:21:04 #auto config tomcat web. #By Precious ################################ #install jdk. tar xf jdk1.8.0_131.tar.gz mkdir -p /usr/java mv jdk1.8.0_131 /usr/java ll /usr/java/jdk1.8.0_131 cat >>/etc/profile<<EOF export JAVA_HOME=/usr/java/jdk1.8.0_131 export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib EOF source /etc/profile #install tomcat web. cd ~ tar xf apache-tomcat-8.0.50.tar.gz -C /usr/local/ mv /usr/local/apache-tomcat-8.0.50 /usr/local/tomcat_vv1.jf.com ll /usr/local/tomcat_vv1.jf.com /usr/local/tomcat_vv1.jf.com/bin/startup.sh sleep 3 ps -ef |grep java netstat -nutlp|grep -wE "8005|8080|8009"
一键部署Tomcat环境-v2
#!/bin/bash #2020-03-15:21:04 #auto config tomcat web. #By Precious ################################ #install jdk. JDK_VER="1.8.0_131" JDK_DIR="/usr/java" JDK_SRC="jdk$JDK_VER" JDK_SOFT="jdk${JDK_VER}.tar.gz" if [ ! -d $JDK_DIR/$JDK_SRC ];then tar xf $JDK_SOFT mkdir -p $JDK_DIR mv $JDK_SRC $JDK_DIR ls $JDK_DIR/$JDK_SRC cat >>/etc/profile<<EOF export JAVA_HOME=$JDK_DIR/jdk1.8.0_131 export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib EOF source /etc/profile fi #install tomcat web. TOMCAT_VHOST="$1" TOMCAT_DIR="/usr/local" TOMCAT_SRC="apache-tomcat-8.0.50" TOMCAT_SOFT="apache-tomcat-8.0.50.tar.gz" cd ~ tar xf $TOMCAT_SOFT -C $TOMCAT_DIR/ mv $TOMCAT_DIR/$TOMCAT_SRC $TOMCAT_DIR/tomcat_$TOMCAT_VHOST ls $TOMCAT_DIR/tomcat_$TOMCAT_VHOST $TOMCAT_DIR/tomcat_$TOMCAT_VHOST/bin/startup.sh sleep 3 ps -ef |grep java netstat -nutlp|grep -wE "8005|8080|8009"
多功能-创建多实例虚拟机
#!/bin/bash #2020-03-15:21:04 #auto config tomcat web. #By Precious ################################ #install jdk. JDK_VER="1.8.0_131" JDK_DIR="/usr/java" JDK_SRC="jdk$JDK_VER" JDK_SOFT="jdk${JDK_VER}.tar.gz" function java_home(){ export JAVA_HOME=$JDK_DIR/jdk1.8.0_131 export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib } if [ ! -d $JDK_DIR/$JDK_SRC ];then tar xf $JDK_SOFT mkdir -p $JDK_DIR mv $JDK_SRC $JDK_DIR ls $JDK_DIR/$JDK_SRC java_home source /etc/profile fi #install tomcat web. TOMCAT_VHOST="$*" TOMCAT_DIR="/usr/local" TOMCAT_SRC="apache-tomcat-8.0.50" TOMCAT_SOFT="apache-tomcat-8.0.50.tar.gz" #MAX_PRT=$(for i in `find /usr/local/ -name server.xml`;do grep "port=" $i;done|sed 's/ / /g'|grep "port="|grep -v "8443"|sed 's/"//g;s/port//g;s/=//g'|sort -n|tail -1) read -p "请输入你需要添加的域名实例 单个或者多个: " TOMCAT_VHOST for TOMCAT_VHOST in $(echo $TOMCAT_VHOST) do MAX_PRT=($(grep -hoE "port=["|0-9]{1,}" `find /usr/local -name "server.xml"`|sed 's/port//g;s/=//g;s/"//g'|uniq|grep -v "8443"|sort -n|tail -1)) if [ -z $MAX_PRT ];then cd ~ tar xf $TOMCAT_SOFT -C $TOMCAT_DIR/ mv $TOMCAT_DIR/$TOMCAT_SRC $TOMCAT_DIR/tomcat_$TOMCAT_VHOST ls $TOMCAT_DIR/tomcat_$TOMCAT_VHOST $TOMCAT_DIR/tomcat_$TOMCAT_VHOST/bin/startup.sh sleep 3 ps -ef |grep java netstat -nutlp|grep -wE "8005|8080|8009" fi IP1=`expr $MAX_PRT - 2080 + 1` IP2=`expr $MAX_PRT - 1080 + 1` IP3=`expr $MAX_PRT + 1` ls $TOMCAT_DIR|grep "$TOMCAT_VHOST" if [ $? -eq 0 ];then echo -e "