Get the App
SLTechnology News&Howtos  ›  Servers  › 

47.nginx+tomcat cluster

Shulou Source: shulou.com Published: 2022-06-02 13:42:47 10月04日 Update

Nginx+tomcat cluster

Tomcat service is a free and open source web application service, which is a lightweight application server, which is generally used in small and medium-sized networks. Tomcat usually runs separately as a Servlet and JSP container on the back end.

Environment deployment: a nginx server accepts requests on the periphery, and multiple tomcat servers process and publish web web pages, which can achieve web load balancing.

To install tomcat:

V install JDK deploy JAVA environment

# tar xzvf jdk-7u65-linux-x64.gz

# mv jdk1.7.0_65/ / usr/local/java

# vim / etc/profile.d/java.sh

Export JAVA_HOME=/usr/local/java

Export PATH=$PATH:$JAVA_HOME/bin

# source / etc/profile.d/java.sh

# java-version

V install and configure Tomcat service

# tar xzvf apache-tomcat-7.0.54.tar.gz

# mv apache-tomcat-7.0.54 / usr/local/tomcat

# / usr/local/tomcat/bin/startup.sh

# netstat-lnupt | grep: 8080

V build a web site based on JAVA

# mkdir-p / web/webapp1

# vim / web/webapp1/index.jsp

JSP test1 page

# vim / usr/local/tomcat/conf/server.xml

Add relevant parameters:

Manually specify the location of the web web page

V deploy nginx server

# yum-y install pcre-devel zlib-devel

# tar xzvf nginx-1.6.0.tar.gz

# cd nginx-1.6.0

# groupadd www

# useradd-g www www-s / bin/false

# / configure-- prefix=/usr/local/nginx-- user=www-- group=www-- with-file-aio-- with-http_stub_module-- with-http_gzip_static_module-- with-http_flv_module-- with-http_ssl_module

# make & & make install

V Editing the nginx configuration file specifies the location of the tomcat server. When users visit the nginx server, they actually visit the web page on the tomcat server.

# vim / usr/local/nginx/conf/nginx.conf

Add relevant parameters:

Upstream tomcat_server {

Server 1.1.1.130:8080 weight=1

Server 1.1.1.120:8080 weight=1

}

Server {

. Omit

Location / {

Root html

Index index.html index.htm

Proxy_pass http://tomcat_server;

}

}

V restart the nginx server

# / usr/local/sbin/nginx-s stop

# / usr/local/sbin/nginx

Tags: Service server web page location parameter environment application configuration balance small and medium-sized multiple container application service manual file time step user site Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno NVidia Shulou Information MySQL Huawei