Tomcat服务在Nginx的负载均衡安装设置教程方法,Nginx负载均衡以及动静分离的原理与配置( 二 )

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

Tomcat服务在Nginx的负载均衡安装设置教程方法,Nginx负载均衡以及动静分离的原理与配置



Tomcat服务在Nginx的负载均衡安装设置教程方法,Nginx负载均衡以及动静分离的原理与配置



Tomcat服务在Nginx的负载均衡安装设置教程方法,Nginx负载均衡以及动静分离的原理与配置


 
动静分离配置(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/

推荐阅读