#源码编译安装单个tomcat服务
install_tomcat1(){
cd /opt
#下载Tomcat源码包
tar xf apache-tomcat-9.0.16.tar.gz #解压源码包
mv apache-tomcat-9.0.16 /usr/local/tomcat #移动Tomcat目录并重命名
mkdir -p /usr/local/tomcat/webapps/test #创建Tomcat测试页面目录
cd /usr/local/tomcat/webapps/test #Tomcat页面内容编写,便于测试
cat >index.jsp<<EOF
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<head>
<title>JSP test4 page</title>
<body>
<% out.println("动态页面4,this is web 4");%>
</head>
</body>
</html>
EOF
#修改Tomcat动态页面路径指向
sed -i '148,149d' /usr/local/tomcat/conf/server.xml
sed -i '148i <Host name="localhost" appBase="webapps"\n unpackWARs="true" autoDeploy="true"\n xmlValidation="false" xmlNamespaceAware="false">' /usr/local/tomcat/conf/server.xml
sed -i '151i <Context docBase="/usr/local/tomcat/webapps/test" path="" reloadable="true" />' /usr/local/tomcat/conf/server.xml
/usr/local/tomcat/bin/startup.sh #启动Tomcat
netstat -natp | grep 8080 #查看Tomcat是否启动成功
}