centos 7一键安装tomcat
最近要在多台服务器上部署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安全和优化,所以剩下的事情要大家自己去搞了,毕竟不同的环境有不同的需求,大家自由发挥吧.
评论: