2、部署两台 Tomcat 应用服务器
所需安装包为:apache-tomcat-9.0.16.tar.gzjdk-8u201-linux-x64.rpm #scp apache-tomcat-9.0.16.tar.gz root@192.168.121.10:/opt#将所需的压缩包在Tomcat1上传给Tomcat2 server,当然我们也可以自己直接将压缩包拉到/opt目录下systemctl stop firewalld.service systemctl disable firewalld.service setenforce 0rpm -qpl jdk-8u201-linux-x64.rpmrpm -ivh jdk-8u201-linux-x64.rpm java -versionvim /etc/profile.d/java.shexport JAVA_HOME=/usr/java/jdk1.8.0_201-amd64export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jarexport PATH=$JAVA_HOME/bin:$PATHsource /etc/profile.d/java.shjava -versioncd /optvim abc.javapublic class abc {public static void main(String[] args){System.out.println("Hello World!")}}[root@localhost?opt]#javac abc.java#用来检测JDK环境是否设置成功[root@localhost?opt]#java abcHello World!cd /opttar zxvf apache-tomcat-9.0.16.tar.gzmv apache-tomcat-9.0.16 /usr/local/tomcat##启动tomcat##/usr/local/tomcat/bin/startup.shnetstat -natp | grep8080
动静分离配置(1)Tomcat1 server 配置mkdir /usr/local/tomcat/webapps/testvim /usr/local/tomcat/webapps/test/index.jsp<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><html><head><title>JSP test1 page</title>#指定为 test1 页面</head><body><% out.println("动态页面 1,http://www.test1.com");%></body></html>vim /usr/local/tomcat/conf/server.xml#由于主机名 name 配置都为 localhost,需要删除前面的 HOST 配置<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <Context docBase="/usr/local/tomcat/webapps/test" path="" reloadable="true"> </Context></Host>/usr/local/tomcat/bin/shutdown.sh /usr/local/tomcat/bin/startup.sh (2)Tomcat2 server 配置mkdir /usr/local/tomcat/tomcat1/webapps/test /usr/local/tomcat/tomcat2/webapps/testvim /usr/local/tomcat/tomcat1/webapps/test/index.jsp<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><html><head><title>JSP test2 page</title>#指定为 test2 页面</head><body><% out.println("动态页面 2,http://www.test2.com");%></body></html>vim /usr/local/tomcat/tomcat1/conf/server.xml#删除前面的 HOST 配置<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <Context docBase="/usr/local/tomcat/tomcat1/webapps/test" path="" reloadable="true" /></Host>/usr/local/tomcat/tomcat1/bin/shutdown.sh /usr/local/tomcat/tomcat1/bin/startup.sh vim /usr/local/tomcat/tomcat2/webapps/test/index.jsp<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><html><head><title>JSP test3 page</title>#指定为 test3 页面</head><body><% out.println("动态页面 3,http://www.test3.com");%></body></html>vim /usr/local/tomcat/tomcat2/conf/server.xml#删除前面的 HOST 配置<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <Context docBase="/usr/local/tomcat/tomcat2/webapps/test" path="" reloadable="true" /></Host>/usr/local/tomcat/tomcat2/bin/shutdown.sh /usr/local/tomcat/tomcat2/
推荐阅读
- Apache Tomcat软件与编辑器IDEA的整合方法,IDEA编辑器整合Apache Tomcat的详细教程
- MongoDB数据库在容器Docker内的安装教程,Docker 部署 MongoDB容器的方法
- Linux系统下DHCP获取IP服务的安装教程,超详细讲解Linux DHCP服务
- 华为C8650+怎么样?
- “中关村在线”报价可信吗?
- 诱惑影院app有毒么?
- 现在1500左右的手几有那些?
- 现在预订魅族MX3,具体什么时候能发货
- 绝地求生训练场装甲车在哪
- 为什么手机会突然没了信号?没有信号几天了,一直显示无服务状态。