码迷,mamicode.com
首页 > 其他好文 > 详细

Tomcat

时间:2020-10-13 16:49:58      阅读:20      评论:0      收藏:0      [点我收藏+]

标签:install   func   function   rtu   star   bsp   div   com   java_home   

一键部署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/ /\n/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 "\033[31m-------------------------------\033[0m"
    exit 1
fi
cd ~
tar xf $TOMCAT_SOFT -C $TOMCAT_DIR/
mv $TOMCAT_DIR/$TOMCAT_SRC $TOMCAT_DIR/tomcat_$TOMCAT_VHOST
sed -i "s/8005/$IP1/g" $TOMCAT_DIR/tomcat_$TOMCAT_VHOST/conf/server.xml
sed -i "s/8009/$IP2/g" $TOMCAT_DIR/tomcat_$TOMCAT_VHOST/conf/server.xml
sed -i "s/8080/$IP3/g" $TOMCAT_DIR/tomcat_$TOMCAT_VHOST/conf/server.xml
$TOMCAT_DIR/tomcat_$TOMCAT_VHOST/bin/startup.sh
sleep 3
netstat -nutlp
ps -ef|grep tomcat
echo -e "\033[32m-------------------------------\033[0m" 
done

 

Tomcat

标签:install   func   function   rtu   star   bsp   div   com   java_home   

原文地址:https://www.cnblogs.com/fengyuanfei/p/13797801.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!