Prepare before deployment:
Iptables and SELinux do not configure, turn off
System CD as Yum source, configure Yum file
SOURCE Package Preparation Jdk-7u65-linux-x64.gz apache-tomcat-7.0.54.tar.gz
Note that the source package is stored in a script that corresponds to each other
Environment Introduction:
One nginx, two tomcat
Configured on the back-end TOMCAT1 and TOMCAT2, respectively:
[Email protected] ~]# VI install_tomcat.sh
#!/bin/bash
# #by Linuxfan
################ #解压 ######################
Tar zxvf/usr/src/jdk-7u65-linux-x64.gz-c/usr/src/
Tar zxvf/usr/src/apache-tomcat-7.0.54.tar.gz-c/usr/src/
############## #config Java env#############
Yum-y Remove Java
mv/usr/src/jdk1.7.0_65//usr/local/java
Cat <<end >>/etc/profile # #设置JAVA的环境变量
Export Java_home=/usr/local/java
Export path=\ $PATH: \ $JAVA _home/bin
END
Source/etc/profile
Java-version
############### #config TOMCAT7 #############
Mv/usr/src/apache-tomcat-7.0.54/usr/local/tomcat7
Reboot
: Wq
Sh-x install_tomcat.sh
After waiting for a reboot, start the service:
/usr/local/tomcat7/bin/startup.sh &&NETSTAT-UTPLN |grep 8080
cd/usr/local/tomcat7/webapps/root/
[Email protected] root]# RM-RF./*
[Email protected] root]# vi index.jsp # #这里注意tomcat1和2服务器的网页不同, respectively, set to Test1,test2
<%@ page language= "java" import= "java.util.*" pageencoding= "UTF-8"%>
<title>jsp TEST PAGE1 </title>
<body>
<% out.println ("Welcome to test site;http://www.test1.com");%>
</body>
: Wq
To access the test separately:
HTTP://IP Address: 8080/
Configure front-end Nginx:
Yum-y Install Pcre-devel zlib-devel openssl-devel
Useradd-s/bin/false Nginx
Tar axvf nginx-1.6.2.tar.gz
CD nginx-1.6.2
./configure--prefix=/usr/local/nginx--user=nginx--group=nginx--with-file-aio--with-http_stub_status_module-- With-http_gzip_static_module--with-http_flv_module \
--with-http_ssl_module &&make &&make Install
Vim nginx.conf
Upstream Tomcat_server {# #在http {}
IP address of server TOMCAT1:8080 weight=1; # #weight表权重, according to the actual situation can be set
IP address of server tomcat2:8080 weight=1;
}
Location/{# #在server {}
root HTML;
Index index.html index.htm;
Proxy_pass Http://tomcat_server;
}
: Wq
/usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/nginx.conf
Multiple Access tests:
Finally, load balancing is achieved
This article is from the "Lp-linux" blog, make sure to keep this source http://linuxlp.blog.51cto.com/11463376/1773579
Linux Enterprise Common Service---Deploy NGINX+TOMCAT load Balancing cluster