centos 7一键安装tomcat

post by rocdk890 / 2017-3-18 16:12 Saturday linux技术
最近要在多台服务器上部署tomcat,这样重复的工作很明显不适合我,直接用脚本来代替我来安装,好了,下面来看脚本吧.
系统:centos 7.x(64位)
软件环境:
tomcat 7.x
jdk 7.x
脚本内容:
cat /root/soft_shell/auto_install_tomcat.sh
#!/bin/sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/opt/bin:/opt/sbin:~/bin
export PATH

# Check the network status
NET_NUM=`ping -c 4 www.baidu.com |awk '/packet loss/{print $6}' |sed -e 's/%//'`
if [ -z "$NET_NUM" ] || [ $NET_NUM -ne 0 ];then
        echo "Please check your internet"
        exit 1
fi

if [ -s server-jre-7u51-linux-x64.tar.gz ];then
	echo -e "\033[40;31m jdk [found]\033[40;37m"
else
	wget http://download.slogra.com/java/server-jre-7u51-linux-x64.tar.gz
fi

if [ -e /usr/java ];then
	echo "delete old exist jdk ..."
	sleep 2
	rm -rf /usr/java
	echo "install new jdk ..."
	mkdir /usr/java
	sleep 2
	tar zxf server-jre* -C /usr/java
else
	mkdir /usr/java
	tar zxf server-jre* -C /usr/java
fi

JDKPATH=`ls /usr/java`
echo ${JDKPATH}

echo " ">>/etc/profile
echo "# JDK ENV">>/etc/profile
echo "JAVA_HOME=/usr/java/${JDKPATH}">>/etc/profile
echo 'PATH=$JAVA_HOME/bin:$PATH'>>/etc/profile
echo 'CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar'>>/etc/profile
echo 'export JAVA_HOME'>>/etc/profile
echo 'export PATH'>>/etc/profile
echo 'export CLASSPATH'>>/etc/profile

if [ -s apache-tomcat-7.0.76.tar.gz ];then
	echo -e "\033[40;31mapache-tomcat-7.0.76.tar.gz [found]\033[40;37m"
else
	wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-7/v7.0.76/bin/apache-tomcat-7.0.76.tar.gz
fi

if [ -e /usr/local/apache-tomcat* ];then
	echo "delete old exist tomcat ..."
	sleep 2
	rm -rf /usr/local/apache-tomcat*
	echo "install new tomcat ..."
	sleep 2
	tar zxvf apache-tomcat* -C /usr/local
else
	tar zxvf apache-tomcat* -C /usr/local
fi

cd /usr/local/apache-tomcat*
TOMCATPATH=`pwd`
echo ${TOMCATPATH}

echo " ">>/etc/profile
echo "# TOMCAT ENV">>/etc/profile
echo "TOMCAT_HOME=${TOMCATPATH}">>/etc/profile
echo 'PATH=$TOMCAT_HOME/bin:$PATH'>>/etc/profile


source /etc/profile

脚本没有做tomcat安全和优化,所以剩下的事情要大家自己去搞了,毕竟不同的环境有不同的需求,大家自由发挥吧.
夜空- 本站版权
1、本站所有主题由该文章作者发表,该文章作者与夜空享有文章相关版权
2、其他单位或个人使用、转载或引用本文时必须同时征得该文章作者和夜空的同意
3、本帖部分内容转载自其它媒体,但并不代表本站赞同其观点和对其真实性负责
4、如本帖侵犯到任何版权问题,请立即告知本站,本站将及时予与删除并致以最深的歉意
5、原文链接:blog.slogra.com/post-691.html

标签: centos 安装 tomcat shell 脚本 tomcat7 install 一键 centos7

评论: