shell脚本一键部署——tomcat安装部署(含可复制代码)
时间:2021-09-22 09:06:31
收藏:0
阅读:44
安装部署tomcat
1、环境准备
将所需安装包传入/opt目录下
2、脚本内容如下:
1 #!/bin/bash 2 #安装部署tomcat 3 4 systemctl stop firewalld 5 systemctl disable firewalld 6 setenforce 0 7 8 #安装JDK 9 cd /opt 10 rpm -ivh jdk-8u201-linux-x64.rpm &> /dev/null 11 java -version 12 13 #设置JDK环境变量 14 cat > /etc/profile.d/java.sh <<EOF 15 export JAVA_HOME=/usr/java/jdk1.8.0_201-amd64 16 export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar 17 export PATH=$JAVA_HOME/bin:$PATH 18 EOF 19 source /etc/profile.d/java.sh 20 21 if [ $? -eq 0 ];then 22 echo -e "\033[34;1m JDK安装完成! \033[0m" 23 fi 24 java -version 25 26 #安装启动Tomcat 27 cd /opt 28 tar zxvf apache-tomcat-9.0.16.tar.gz &> /dev/null 29 mv apache-tomcat-9.0.16 /usr/local/tomcat 30 ##启动tomcat 31 /usr/local/tomcat/bin/startup.sh 32 33 if [ $? -eq 0 ];then 34 echo -e "\033[34;1m tomcat安装完成! \033[0m" 35 fi
3、运行脚本结果:
原文:https://www.cnblogs.com/weq0805/p/15310291.html
评论(0)