Integration of Apache2.2 and Tomcat5.5 in JSP environment Configuration

Source: Internet
Author: User

Apache and Tomcat are two projects under the Apache Foundation.

One is the http web server and the other is the servlet container. The latest 5.5.X series implements servlet 2.4/JSP 2.0 Spec. In our production environment, Apache is often used as the front-end server and Tomcat as the back-end server. In this case, we need a connector that transfers all Servlet/JSP requests to Tomcat for processing. Before Apache2.2, there are generally two components to choose from. Mod_jk and mod_jk2. Later, mod_jk2 was not updated, but mod_jk was updated. Therefore, mod_jk is usually used for Apache and Tomcat connectors. It should be noted that mod_jk supports Apache 1. x and 2. X series.

However, since Apache2.2 came out, you have another option, that is, proxy-ajp. We all know that the proxy module in Apache can implement the two-way proxy function, which is very powerful. In fact, it is natural to use the proxy module to implement the connector. The proxy module sends the relevant requests to a specific host and then returns the results. The functional requirement of the connector is to transfer all requests to Servlet/JSP to the backend Tomcat. In addition, the use of proxy-ajp is more efficient than that of mod_jk In the FreeBSD email list. As far as I am concerned, at least using the Apache built-in module is more reliable than compiling it separately.

Apache2.2 and tomcat5.5 are good combinations and can be used as development environments or working servers. Download the following files before Configuration:

1. Download JDK

Http: // 192.18.108.228/ECom/EComTicketServlet/BEGIN7CF7E6A4BCB54064E5D90FCCE00D7048/-2147483648/1579524843/1/732086/731822/1579524843/2ts +/westCoastFSEND/jdk-1.5.0_07-oth-JPR/2/jdk-1.5.0_07-oth-JPR

2. Download apache2.2

Http://mirror.vmmatrix.net/apache/httpd/binaries/win32/apache_2.2.2-win32-x86-no_ssl.msi

3. Download tomcat5.5.17

Http://apache.justdn.org/tomcat/tomcat-5/v5.5.17/bin/apache-tomcat-5.5.17.exe

1. install and configure JDK

JDk installation is not much said, but do not forget to set environment variables.

Ii. Install and test apache

If you have already installed IIS before installation, stop the IIS service first. Because both IIS and apache use port 80 by default, otherwise it will conflict.

Similarly, if you run the installation apache_2.2.2-win32-x86-no_ssl.msi directly, we recommend that you select a simple path, such as D: apache2.2. During installation, you are required to enter some information about the server, such as the domain name or administrator email address. The information will be added to the httpd. conf file.

After installing and configuring the httpd. conf file, go to D: apache2.2conf.

Use the text editor to open httpd. conf and add index. jsp after DirectoryIndex index.html.

Test. Enter http: // localhost/in IE. If apache works, you can see "It works! "Such a page.

3. Install and test tomcat

Run and install tomcat directly. The installation path is D: omcat5.5.

After installation, add the environment variable TOMCAT_HOME. The variable value is "D: omcat5.5"

Finally, test tomcat. Because tomcat uses port 8080 by default, enter http: // localhost: 8080 in IE. Normally, a kitten's page is displayed.

4. Integrate apache and tomcat

Many of them are integrated through mod_jk on the Internet. Because apache2.2 already supports tomcat, we use proxy to integrate tomcat and stop apache and tomcat. Open the httpd. conf file and

LoadModule proxy_module modules/mod_proxy.so

LoadModule proxy_ajp_module modules/mod_proxy_ajp.so

Remove the # sign and add it at the end of the file.

ProxyPass/images /!

ProxyPass/ajp: // 127.0.0.1: 8009/

ProxyPassReverse/ajp: // 127.0.0.1: 8009/

The above are just simple optimizations for apache.

5. Test the integrated apache + tomcat

Start apache, start tomcat, and prepare the jsp file of the following code for testing.

<% @ Page contentType = "text/html; charset = gb2312" %>
<HTML>
<HEAD>
<TITLE> JSP test page </TITLE>
</HEAD>
<BODY>
<% Out. println ("</BODY>
</HTML>

 

Save as test. jsp

Create a folder named myjsp under D: omcat5.5websiteroot and put test. jsp in it.

Enter http: // localhost: 8080/myjsp/test. jsp in IE

Enter http: // localhost/myjsp/test. jsp

If Hello World is displayed twice! It indicates that the integration has been successful.

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.