JSP environment configuration Apache2.2 and Tomcat5.5 consolidation

Source: Internet
Author: User
Tags add end iis variable win32 domain name tomcat



Apache and Tomcat are the two projects under the Apache Foundation.

One is the HTTP Web server, the other is the servlet container (servlet container), and the latest 5.5.X series implements the Servlet 2.4/jsp 2.0Spec. In our production environment, often need to do Apache front-end server, Tomcat to do back-end servers. At this point we need a connector, and the role of this connector is to transfer all servlet/jsp requests to Tomcat for processing. Before Apache2.2, there are typically two components to choose from. MOD_JK and MOD_JK2. Later MOD_JK2 did not update, instead of updating the mod_jk, so now generally use MOD_JK to do Apache and Tomcat connectors. The point to be noted is that MOD_JK supports Apache 1.x and 2. X series.

However, since Apache2.2 out, you have a choice, that is PROXY-AJP. You know the proxy module in Apache, you can achieve two-way agent function, the function is very powerful. In fact, from the realization of the principle of the connector, using proxy module to achieve is very natural. The function of the proxy module is simply to send the relevant request to a specific host and return the result. The functional requirement of the connector is to transfer all requests for servlet/jsp to Tomcat in the background. and the FreeBSD mailing list says that using PROXY-AJP is more efficient than mod_jk. As far as I am a layman, it is more reliable to use Apache self-contained modules than to compile them separately.

apache2.2 and tomcat5.5 are a good combination, either as a development environment or as a working server. You need to download the following files before configuring:

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/jdk-1.5.0_07-oth-jpr:2/jdk-1_5_0_07- Windows-i586-p.exe

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

First, install and configure the JDK

JDK installation is not much to say, but must not forget to set environment variables.

Second, install and test Apache

If you have IIS installed before installation, stop the IIS service first. Because both IIS and Apache use 80 ports by default, they will conflict.
Also directly run the installation Apache_2.2.2-win32-x86-no_ssl.msi, it is recommended to select a simple path, such as d:apache2.2. The installation will require some information about this server, such as domain name, admin mailbox, which will be added to the httpd.conf file.

After installing the configuration httpd.conf file, under d:apache2.2conf

Open httpd.conf with a text editor and add index.jsp after DirectoryIndex index.html

Test, enter http://localhost/in IE, if Apache work should be able to see "It works!" Such a page.

Third, install and test tomcat

Run install tomcat directly, installation path is d:omcat5.5

Add environment variable Tomcat_home after installation, the variable value is "d:omcat5.5"

Finally Tomcat is tested because Tomcat uses 8080 ports by default, so when IE enters http://localhost:8080, it will see a kitten's page as it works.

Iv. integrating Apache and Tomcat

Many of the online are integrated through MOD_JK, because the apache2.2 itself already supports Tomcat, so use proxy to integrate Tomcat, first to stop Apache and Tomcat. Then open the httpd.conf file and put

LoadModule Proxy_module modules/mod_proxy.so
LoadModule Proxy_ajp_module modules/mod_proxy_ajp.so

Before the # number is removed, added at the end of the file

Proxypass/images/!

proxypass/ajp://127.0.0.1:8009/

proxypassreverse/ajp://127.0.0.1:8009/


The top few are just simple optimizations for Apache.
Apache+tomcat after the final Test integration

Start Apache, then start Tomcat, and prepare the following code for the JSP file for testing.

<%@ page contentType="text/html;charset=gb2312" %>


JSP Test page


<%out.println("
Hello World!

");%>


Save As Test.jsp


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

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

And then enter http://localhost/myjsp/test.jsp


If both show Hello world! the description has been successfully integrated.

Related Article

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.