Consolidate Apache and Tomcat build Web servers

Source: Internet
Author: User
Tags php and versions tomcat tomcat server linux

Linux is the most common Web server, and in this section we will build a java/jsp operating platform by consolidating Apache and Tomcat, detailing the process of building a Web server.

The necessity of the integration of Apache and Tomcat

Apache is the most popular Web server, open source, support cross-platform applications (can run on almost all Linux, Unix, Windows system platforms), especially for Linux support is quite perfect.

The advantages of Apache are:

Powerful, Apache has a lot of functional modules, can be compiled according to the needs of the module.

Simple configuration, Apache configuration file is very simple, with simple configuration can achieve powerful features.

Fast, Apache processing static paging file efficiency is very high, can deal with large concurrent and high load access requests.

Performance is stable, Apache performance is excellent under high load request, execution efficiency is very high.

But Apache also has its own drawbacks:

Support only static Web pages, for JSP, PHP and other dynamic Web pages do not support

Apache is a process based structure that consumes more system overhead than threads, and therefore is less suited to a multiprocessor environment.

Tomcat is a collaboration between Sun and Apache, and has the following advantages: Jspserver

Supports servlet and JSP, and can handle dynamic Web pages very well.

Cross-platform: Tomcat is a Java program, so you can use it as long as you have a JDK, and you don't need to consider the operating system platform.

However, Tomcat also has its own drawbacks:

Processing static pages is inefficient: Tomcat itself can be used as a web Server, but Tomcat does not have the Apache fast handling of static pages.

Configurable is not strong: Tomcat is not as simple, stable and strong as Apache.

To sum up, through mutual integration just make up for their shortcomings, through the integration can be achieved:

When a client requests a static page, the Apache server responds to the request.

When a client requests a dynamic page, the Tomcat server responds to the request.

Through the Apache information filtering, the Web site moving, static page separation, to ensure the application of scalability and security.

Now that you want Apache and Tomcat to work together, you need to have a connector to connect them, which is the connector below, and the next section specifically about connector selection and use.

Two, Apache and Tomcat connectors

Apache is a modular Web server, which means that the core contains only the modules that implement the most basic functionality. The extension function can be dynamically loaded as a module to implement. To allow Apache and Tomcat to work together, open source enthusiasts have developed a lot of available modules, and before the Apache2.2 version, there are typically two modules to choose from: MOD_JK2 and MOD_JK,MOD_JK2 modules are early connectors, moving, Regular expressions can be used on static page filtering, so the configuration is flexible, but the MOD_JK2 module now has no developer support and the version update stops. The MOD_JK module is inherited from the Jk2 module, and the MOD_JK module supports Apache 1.x and 2. X-series versions, now generally use MOD_JK to do Apache and Tomcat connectors.

After the Apache2.2 version, there are two connectors available to choose from, that is, Http-proxy and PROXY-AJP module, Apache Proxy (proxy) module can achieve two-way agent, the function is very powerful, from the realization of the principle of the connector, with the Http-proxy module to achieve is also very natural Things, just open Tomcat's HTTP function, and then use the Apache proxy agent function to the dynamic request to Tomcat processing, and static data to the Apache itself. The PROXY-AJP module was developed specifically for Tomcat consolidation and was specifically represented through the AJP protocol to tomcat requests. According to the official test, PROXY-AJP is more efficient than http-proxy, so in Apache2.2 later versions, using the PROXY-AJP module as the Apache and Tomcat connectors is a good choice.

What needs to be said is that these connection functions are implemented by loading the corresponding function module in Apache, such as the above mentioned mod_jk, MOD_JK2, PROXY-AJP module, all have to compile the corresponding module in advance through the source code, and then dynamically load through the Apache configuration file To implement the connector function. This is also the advantage of Apache.

In the following story, we will focus on the installation configuration and implementation of MOD_JK as a connector.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.