Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

47.nginx+tomcat cluster

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report