#!/bin/bash
############# #检测软件包是否安装 ########################
For i in {java,java-1.8.0-openjdk-devel};
Do
If Rpm-qa | grep $i >>/dev/null;
Then
Echo-e "\033[32m $i installed \033[0m"
Else
Yum-y Install $i
Fi
Done
############## #查看java版本 #############################
Java-version
ECHO-E "\033[32m version display \033[0m"
########### #部署tomcat -9.0.7############################
For s in {apache-tomcat-9.0.7};
Do
If Rpm-qa | grep $s >>/dev/null;
Then
Echo-e "\033[32m $i installed \033[0m"
Else
Wget–c http://mirrors.hust.edu.cn/apache/tomcat/tomcat-9/v9.0.7/bin/apache-tomcat-9.0.7.tar.gz
Tar zxf apache-tomcat-9.0.7.tar.gz
Mv-f Apache-tomcat-9.0.7/usr/local/tomcat
Fi
Done
ECHO-E "\033[32M Deployment Complete \033[0m"
############# #配置环境变量 ###############################
Cat >>/etc/profile<<end
Export java_home= '/usr/lib/jvm/jre '
Export catalina_home= '/usr/local/tomcat '
End
Source/etc/profile
ECHO-E "\033[32M environment variable configuration complete \033[0m"
############ #启动tomcat ##################################
/usr/local/tomcat/bin/startup.sh
Echo-e "\033[32m Tomcat boot \033[0m"
############ #监听8080端口 ################################
Netstat-anutpl | grep 8080
Echo-e "\033[32m Java is listening \033[0m"
########### #移动war包 ####################################
MV tech-sdkwrapper.war/usr/local/tomcat/webapps/
Echo-e "\033[32m Complete War movement \033[0m"
Echo-e "\033[32m please visit \033[0m in browser"
Note: Because the current script is in the same directory as the Tomcat package and the war package, if it is not in the same directory, you need to modify the script appropriately.
Browser access mode:/HTTP Server ip:8080/
Browser access to the war package new features:/HTTP Server ip:8080/tech-sdkwrapper/remember not to access the suffix band. War directory
CENTOS7 Deploying the Java Environment