How to configure Tomcat 5 and IIS 5 work together

Source: Internet
Author: User
Tags filter format net variables socket access apache tomcat microsoft iis
IIS Catalog Summary Preparation download Java 2 SDK 1.4.2 (or later) Tomcat 5.0.24 (or later) Tomcat WEB Server connector installation Java 2 SDK Tomcat 5 Tomcat JK2 IIS Connector setting Tomcat Tomcat IIS connectors Windows IIS setting ISAPI filter Creating a virtual directory used by an ISAPI filter restarting the IIS Service Test Tomcat IIS reference sequence
Recently encountered a project, unavoidable need to coordinate IIS and Tomcat work together, while parsing ASP and JSP two scripting languages. See Tomcat official howto, several operations did not succeed. View the online discussion, found that the Chinese information is tomcat4.x version of the configuration method, old is not applicable. Later, the study and the operation of the English data were successful. In view of the lack of Chinese materials to discuss this issue, I decided to organize my disposition process, and I hope it will be helpful to the lovers. This article discusses the content, the writing format imitates http://virtualict.net/support/kb/iis6-Tomcat5-JK2.html, and references some of the text. In my configuration, browsing the data process, I feel the IIS, Apache Tomcat, JK2, and other official documents on this issue is not exhaustive, and sometimes even feel misled to increase the difficulty of solving problems, look forward to discussing with you.

My Configuration Environment Window 2K Professional SP4 IIS 5.0j2sdk1.4.2_04jakarta-tomcat-5.0.24jakarta-tomcat-connectors-jk2.0.4

The path involved in the configuration process is not a system requirement if there are no special instructions, and you can modify it to suit your machine's environment.

Here is another automatic installer, using the method this article does not discuss ISAPI redirector jk2.02 installer-integrating Tomcat with IIS
Summary
This is an article on how to install, configure Tomcat 5 Java Servlet & JSP Services to Microsoft IIS 5.0 server, this article is my own configuration process and experience of the summary, and recommended some of my great help to the document. It takes only 15 minutes for a friend to master the method to complete the configuration process.
Preparatory work


Microsoft Windows Professional, IIS5 is installed and working properly

Software to download:
Java 2 Standard Edition Software Development Kit 1.4.2.04 (or later) Jakarta Tomcat 5.0 (or later) Jakarta Tomcat CONNECTORS-JK2 .0.4 (or later)
Download

Due to a version update issue, there is no exact download address for the software, but the following link users can easily find the exact address of the desired software.
Java 2 SDK 1.4.2 (or later)
From java.sun.com/downloads/Select the J2se 1.4.2 (or later) all platforms







Then follow the prompts to enter the file list page, download the file


Tomcat 5.0.24 (or later)
The compiled version of the for win from Apache Jakarta. Tomcat 5.x should be at the bottom of the page. When this article was written, Tomcat had released version 5.0.25, but the configuration process was the same.



Select 5.0.24 executable file (or later)
Tomcat Web Server Connector
Also download the page in Apache Jakarta. The Tomcat Web Server Connector is under the Tomcat 5.0.24 link



Select JK2 Compiled version



Select Win32, then select Download Jakarta-tomcat-connectors-jk2.0.4-win32-iis.zip



Note that the file name shown in this directory list is truncated, so you need to observe the prompts in the browser's status bar to confirm that the file you are downloading should end with "... iis.zip".
Installation
We recommend that you put the downloaded files in the same folder.


Java 2 SDK
Run J2sdk-1_4_2_04-windows-i586-p.exe follow the prompts to install



You can change the installation path to where you're used to
Tomcat 5
Run Jakarta-tomcat-5.0.24.exe follow the prompts to install.



If you want to change the installation path, you can do so at this step.



Can be changed to other paths, such as C:\Tomcat 5.0



Set the password, the proper custody of the password, do not recommend a blank password.



This step is to select the JDK path for the local machine, in general, the installation files will automatically search and display, if not displayed correctly, you can manually change.



After a successful installation, the program prompts to start Tomcat and view the Readme document.

Note: Before starting Tomcat, make sure that no other services are already consuming 8080 ports (tomcat default port) and Port 8009 (Tomcat's AJP13 connector port)

Tomcat loads icon in system tray after normal startup



The right mouse button on the icon can see some setup items



Click Configure ... See the following display, select startup type for automatic to start automatically.


Tomcat JK2 IIS Connectors
Extract Jakarta-tomcat-connectors-jk2.0.4-win32-iis.zip to get the following folder



Visible after entering \bin\



Cut/Copy Isapi_redirector2.dll files to Tomcat's bin\ directory



Create a new directory win32\i386\ and paste Isapi_redirector2.dll.



Remember this path and use it later when you configure IIS. This path is not required by the system and can be changed!

Now you can delete the Jakarta-tomcat-connectors-jk2.0.4-win32-iis directory, this file is useless. In fact, in Jakarta-tomcat-connectors-jk2.0.4-win32-iis.zip, we only used a Isapi_redirector2.dll file.
Set Tomcat
Enter Tomcat ' s conf\ folder.



To support the JK2 connector, you may need to modify the Jk2.properties file. In most cases, you can leave this file in the default state, and I have not modified this file in my multiple configuration procedures.

# # This FILE May is overriden at RUNTIME. Make sure TOMCAT are stoped## when you EDIT the file.## COMMENTS'll be _lost_## documentation of the FORMAT in Jkmain JAV adoc.# Set the desired handler list# handler.list=apr,request,channeljni## Override The default port for the Socketchannel # channelsocket.port=8019# Default: # channelunix.file=${jkhome}/work/jk2.socket# Just to check if the ' config is Worki ng# shm.file=${jkhome}/work/jk2.shm# in order to enable JNI with any channeljni directive# channeljni.disabled = 0# and one Of the following directives:# apr.jnimodeso=/opt/apache2/modules/mod_jk2.so# If set to inprocess the MOD_JK2 would Registe R Natives itself# This would enable the starting of the Tomcat from mod_jk2# apr.jnimodeso=inprocess

Now it's workers2.properties, this file needs to be created by itself, the contents are as follows (there is a copy in the attachment) red this line to note, the "C:\Tomcat 5.0\work\" This path to modify into your own path, And Jk2.shm This file does not have to worry, it does not exist now and does not matter, it will be automatically created when needed.

[Shm:]info=shared memory file. Required for multiprocess Serversfile=c:\tomcat 5.0\work\jk2.shmsize=1000000[channel.socket:localhost:8009]info= AJP13 worker, connects to Tomcat instance using AJP 1.3 Examples, map requests for all JSPs pages to tomcat.context=/jsp-examples[uri:/servlets-examples/*]info=servlet examples , map requests for all servlets to Tomcat.context=/servlets-examples

Read the discussion on the Internet, some friends in the process of configuration problems appear here, so say a few words: This file specifies the directory to parse JSP, that is, "http://xxxxx/dir/aa.jsp" This url "dir", such as our site to increase/dir/ This path, and so that the JSP below this path can be parsed, then you need to add such a phrase to the Workers2.properties file

[uri:/dir/*] info=jsp examples, map requests for all JSP pages to Tomcat. Context=/dir

and create a "/dir/" directory in Tomcat's working directory. For example, we have until now, Tomcat's working directory is the default "/root/", then we need to "/root/" path under the new "/dir/" directory, and place aa.jsp file. After the service is reset, we can access the aa.jsp file using a URL such as "http://xxxxx/dir/aa.jsp". Some friends in the past mistakenly thought that "dir" is the path in the IIS working directory, the runtime cannot display the page, or the JSP code does not parse, in fact, this is the path set up the problem. It is worth noting that if both IIS and Tomcat's working directory have "/dir/" at the same time, the server connects this path to Tomcat processing. When your tomcat and IIS work together, you can modify this file at any time to add new directories to support JSP operations.

Here are more rules about worker2.properties this file.

Right-click the Tomcat Service icon in the system tray, select "Stop service" and turn off the service.



Locate the Apache Tomcat service in the Administrative tools-services and make sure it is started.


Tomcat IIS Connectors
You have placed Isapi_redirector2.dll under your path, this example is C:\Tomcat 5.0\bin\win32\i386



Now you need to add some necessary registration information to the registry, which redirector read when invoked by IIS. Create a. reg file

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE Oftware\apache Software Foundation\jakarta Isapi redirector\2.0] "workersfile" = "C:\\Tomcat 5.0\\ Conf\\workers2.properties "" Extensionuri "="/jakarta/isapi_redirector2.dll "" loglevel "=" Debug "" serverRoot "=" C:\\ " Tomcat 5.0\\ "

Write the above text in Notepad and save it as Reg.reg (there is a copy in the attachment)

Double-click the. reg file



Success is shown as follows:



You can see in the registry:





You can now delete this. reg file.
Windows
Add two system environment variables, they are catalina_home and java_home.

Right-click My Computer on the desktop, select Properties-Advanced-environment variables

Catalina_home point to your Tomcat installation directory, this example is C:\Tomcat 5.0

Java_home points to the Java SDK installation directory, which is C:\j2sdk1.4.2_04 in this example
IIS Installs ISAPI filters
Enter the ISAPI filter interface



Click on the Add button to type a new filter name that can be started at random



Then click the Browse button and select Isapi_redirector2.dll. This example is C:\Tomcat 5.0\bin\win32\i386\isapi_redirector2.dll.



Click OK. The new filter will not take effect until IIS is reset, we do not start again, we do it later.



Click OK to save the changes and exit the Site Properties dialog box.

Note: You can select a specific site to set up, add filters, or add filters to all sites in the IIS tree on the left side of the "computer", bring up the properties, select "Edit" The main Properties dialog box



Pull up the main Properties dialog box and add a filter.




Virtual directories required to create a filter
Select to load the Tomcat service point, right-click to select New, and then select Virtual Directory



Create a virtual directory with an alias of Jakarta. Note that this name is a fixed value, do not spell wrong!



Specifies that the directory is the Isapi_redirector2.dll directory. This example is C:\Tomcat 5.0\bin\win32\i386.



Select Execute to make it available



After you successfully set up a virtual directory, you should see the following display in the admin.


Restart the IIS Service
Select the computer, right-click, and select Restart IIS



Select Restart Internet service and click OK



Administrative tools in the operating system-the Event Viewer can view the startup of the service, and Isapi_redirector2.dll writes its error message to the Event Viewer instead of writing to a file like an earlier version.

After startup in the IIS console, in the list of ISAPI filters in the site properties, you can see the status of the Tomcat connector, with the green up arrow on it.


Test Tomcat
First Test the example of Tomcat installation and use Tomcat's own server and port

Servlets:http://localhost:8080/servlets-examples/in the test server

Jsp:http://localhost:8080/jsp-examples/in the test server

Test Tomcat Admin Interface: http://127.0.0.1:8080/admin/
Iis
Now we have access to the same example in IIS to test that the connector is working, and that changing the address and port is consistent with your IIS

http://localhost/servlets-examples/

http://localhost/jsp-examples/



If everything works, you've made IIS5 to parse the Jsp&servlet program with the work of the Tomcat JK2 IIS Connector, congratulations. And be happy to get your experience and feedback on this article. (zself@vip.cc163.com)
Reference documents
JK documentation (IISHOWTO) http://virtualict.net/support/kb/iis6-Tomcat5-JK2.html

Http://info.cc163.net/NewIIS5+TomcatHowTo/NewIIS5+Tomcat5HowTo.htm


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.