Nginx + Tomcat server Load balancer configuration Wu guangke 51cto font size: T | T one-click favorites, view at any time, share friends! Nginx + Tomcat is currently the mainstream Java Web architecture. How can we make nginx + Tomcat work at the same time? Can we also say how to use nginx to reverse proxy Tomcat backend balancing? Next, let's take a look at ad in detail: the course video of the WOT Global Software Technology Summit on the Beijing site was published. It met with the WOT Technology Conference on September. Currently, nginx + Tomcat is the mainstream Java Web architecture. How can we make nginx + Tomcat work at the same time, you can also say how to use nginx to reverse proxy Tomcat backend balancing? Directly install the configuration as follows: 1, Java JDK installation: # download the appropriate JDK software package, and then unzip the installation, I here the package name is: jdk-7u25-linux-x64.tar.gz tar-xzf jdk-7u25-linux-x64.tar.gz; mkdir-P/usr/Java/; MV jdk1.7.0 _ 25 // usr/Java. # configure the environment variable so that JDK can be referenced anywhere. The following configuration is used: # Add the following statement to the end of VI/etc/profile: export java_home =/usr/Java/jdk1.7.0 _ 25 export classpath = $ classpath: $ java_home/lib: $ java_home/JRE/lib export Path = $ java_home/bin: $ java_home/JRE/bin: $ path: $ homr/bin # source/etc/Prof Ile # make the environment variable take effect immediately # JAVA -- version # Check the Java version. If JDK 1.7.0 _ 25 is displayed, the Java JDK is successfully installed. 2. nginx installation: wget http://nginx.org/download/nginx-1.2.6.tar.gz useradd WWW tar zxvf nginx-1.2.6.tar.gz CD nginx-1.2.6 /. /configure -- user = WWW -- group = WWW -- prefix =/usr/local/nginx \ -- with-http_stub_status_module -- with-http_ssl_module make & make install # nginx installation is complete, and then use the command: /usr/local/nginx/sbin/nginx-T test OK, indicating nginx installation is successful. /Usr/local/nginx/sbin/nginx press enter to start nginx. You can access http: // ip/to view the default nginx page. 3, tomcat installation: # official website download Tomcat 6.0.30 or other versions: CD/usr/src & tar xzf apache-tomcat-6.0.30.tar.gz # directly decompress can be used, decompress to complete the execution, copy two Tomcat servers at the same time, named tomcat1 tomcat2 mv apache-Tomcat-6.0.30/usr/local/tomcat1 CP/usr/local/tomcat1/usr/local/tomcat2-R # modify the tomcat1 and tomcat2 ports respectively, there are three ports to be modified, respectively: shutdown port: 8005 is mainly responsible for starting and closing. AJP port: 8009 is mainly used for AJP balancing (usually used for Apache and tomcat integration). http port: 8080 can be directly accessed through web pages (nginx + tomcata integration) # Note * If Layer 1 is divided into three ports The port number is 8005 8009 8080, so the port number of tomcat2 is + 1, that is, 8006 8010 8081 # on a server, the port number cannot be repeated; otherwise, an error is reported. # After modifying the port, start two Tomcat servers and run the following command: # How to prompt that the file is not available or has insufficient permissions? The bin directory of Tomcat needs to grant the execution permission to the sh file: chmod o + x *. SH/usr/local/tomcat1/bin/startup. SH/usr/local/tomcat2/bin/startup. sh # After the instance is started, use netstat-tnl to view the six ports, that is, tomcat1 tomcat2 is successfully started. You can use http: // ip: 8080 http: // ip: 8081 to access the default Tomcat page. # If you need to modify the Tomcat release directory as your own directory, you need to make the following adjustments to create two release directories: mkdir-P/usr/webapps/{www1, www2} edit VI/usr/local/tomcat1/CONF/server. add the following content to the last line of XML
Nginx + Tomcat server Load balancer Configuration