Configure tomcat5 and iis5 to work together

Source: Internet
Author: User
Tags create directory apache tomcat microsoft iis
Directory
  1. Collation
  2. Summary
  3. Preparations
  4. Download
    1. Java 2 SDK 1.4.2 (or later)
    2. Tomcat 5.0.24 (or later)
    3. Tomcat Web Server Connector
  5. Install
    1. Java 2 SDK
    2. Tomcat 5
    3. Tomcat JK2 IIS Connector
  6. Set
    1. Tomcat
    2. Tomcat IIS Connector
    3. Windows
    4. IIS
      1. Set ISAPI filter
      2. Create a virtual directory used by the ISAPI filter
      3. Restart the IIS service
  7. Test
    1. Tomcat
    2. IIS
  8. References
Collation

Recently, I encountered a project where I had to coordinate IIS and Tomcat and parse the ASP and JSP scripting languages at the same time.
Check the official Tomcat howto. The operation was unsuccessful. View the online discussion and find that all Chinese documents are about Tomcat 4.x configuration methods. Later, I learned and operated based on multiple pieces of English documents.

In view of the lack of Chinese materials to discuss this issue, I decided to sort out my configuration process. I hope it will be helpful to my colleagues.

The content and writing format of this article are modeled on http://virtualict.net/support/kb/iis6-tomcat5-jk2.html, and used in simplified text.

During the process of configuration and Data Reading, I felt that official documents such as IIS, Apache Tomcat, and JK2 were not detailed about this issue, and sometimes I felt misled, this increases the difficulty of solving the problem and is expected to be discussed with you.

My configuration Environment
Window 2 k Professional SP4
In IIS 5.0
J2sdk1.4.2 _ 04
Jakarta-tomcat-5.0.24
Jakarta-tomcat-connectors-jk2.0.4

If there are no special instructions on the paths involved in the configuration process, they are not system requirements. You can modify them to adapt to the environment of your machine.

Here is another automatic installation program. The usage is not discussed in this article.
ISAPI redirector jk2.02 installer-integrating Tomcat with IIS

Summary

This is an article about how to install and configure Tomcat 5 Java Servlet & JSP service to Microsoft IIS 5.0 server. This article is a summary of my own configuration process and experience, I also recommended some documents that helped me a lot.
It takes only 15 minutes to complete the configuration process.

Preparations

Microsoft Windows 2000 Professional and iis5 have been installed and work properly

Software to be downloaded:

  • 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 version updates, the software is not provided here, but you can easily find the exact address of the required software based on the link below.

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 go to the file list page and download the file.



Tomcat 5.0.24 (or later)

The compiled version of for win from Apache Jakarta. Tomcat 5.x should be at the bottom of the page. At the time of writing this article, tomcat has released version 5.0.25, but the configuration process is the same.

Select 5.0.24Executable files(Or later)



Tomcat Web Server Connector

Also on the Apache Jakarta download page. The Tomcat web server connector is linked to Tomcat 5.0.24.

Select JK2 compiling version

Select Win32. Then select and download jakarta-tomcat-connectors-jk2.0.4-win32-iis.zip.

Note:The file name displayed in this directory list is truncated, so you need to observe the prompt in the browser status bar to confirm that the file you are about to download should end with "...iis.zip"



Install

We recommend that you put the downloaded file in the same folder.

Java 2 SDK

RunJ2sdk-1_4_2_04-windows-i586-p.exeFollow the prompts to install

You can change the installation path to your preferred location.

 



Tomcat 5

RunJakarta-tomcat-5.0.24.exeFollow the prompts to install.

To change the installation path, follow these steps.

You can change it to another path, such as C:/tomcat 5.0.

Set the password and keep it safe. It is not recommended to leave it empty.

In this step, select the JDK path of the Local Machine. Generally, the installation file is automatically searched and displayed. If the installation file is not displayed correctly, you can manually change it.

After successful installation, the program will prompt to start Tomcat and view the README documentation.

Note:Before starting tomcat, make sure that no other services in the system are using port 8080 (default Tomcat port) and Port 8009 (Tomcat's ajp13 connector port)

After Tomcat is started normally, the icon is loaded in the system bar.

Right-click the icon to view some settings.

Click Configure ....Startup type is set to Automatic startup of Automatic startup.



Tomcat JK2 IIS Connector

ExtractJakarta-tomcat-connectors-jk2.0.4-win32-IIS.zipThe following folder is displayed:

Enter/Bin/Visible later

Cut/copyIsapi_redirector2.dllFile to Tomcat'sBin/Directory

Create directoryWin32/i386/And PasteIsapi_redirector2.dll.

Remember this path, which will be used later when you configure IIS. This path is not required by the system. It can be changed!

Can be deleted nowJakarta-tomcat-connectors-jk2.0.4-win32-IISDirectory. The file is useless. In factJakarta-tomcat-connectors-jk2.0.4-win32-IIS.zipWe only useIsapi_redirector2.dllOne file



Set Tomcat

Go to Tomcat'sConf/Folder.

To support the JK2 connector, you may need to modifyJk2.propertiesFile. In most cases, keep the default status of this file. I have not modified this file for many configuration procedures.

## THIS FILE MAY BE OVERRIDEN AT RUNTIME. MAKE SURE TOMCAT IS STOPED ## WHEN YOU EDIT THE FILE. ## COMMENTS WILL BE _LOST_ ## DOCUMENTATION OF THE FORMAT IN JkMain javadoc. # 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 the config is working # shm.file=${jkHome}/work/jk2.shm # In order to enable jni use 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 will Register natives itself # This will enable the starting of the Tomcat from mod_jk2 # apr.jniModeSo=inprocess 

Now it's your turnWorkers2.properties,This file needs to be created by yourself. The content is as follows (there is a copy in the attachment)
Note the red line, and change the path "C:/tomcat 5.0/work/" to your own path, while jk2.shm does not need to worry about this file, it does not exist and does not matter. It will be automatically created as needed.

[shm:] info=Shared memory file. Required for multiprocess servers file=C:/Tomcat 5.0/work/jk2.shm size=1000000 [channel.socket:localhost:8009] info=Ajp13 worker, connects to tomcat instance using AJP 1.3 protocol tomcatId=localhost:8009 [uri:/jsp-examples/*] info=JSP examples, map requests for all JSP pages to Tomcat. context=/jsp-examples [uri:/servlets-examples/*] info=Servlet examples, map requests for all servlets to Tomcat. context=/servlets-examples 

After reading the discussion on the Internet, some of my friends encountered problems during the configuration process. So I would like to say a few more words:
This file specifies the directory for parsing JSP, that is, "http: // XXXXX/DIR/AA. JSP "dir" in this URL. For example, if we want to add the/DIR/path to our website and parse the JSP file under this path, you needWorkers2.propertiesAdd such a paragraph to the file

[URI:/DIR/*]
Info = jsp examples, map requests for all JSP pages to Tomcat.
Context =/Dir

Create the "/DIR/" directory in the Tomcat working directory. For example, till now, the Tomcat working directory is the default "/root/", so we need to create a "/DIR/" directory under the "/root/" path, and place AA. JSP file. After restarting the service, we can use a URL such as "http: // XXXXX/DIR/AA. jsp" to access the AA. jsp file.
In the past, some friends mistakenly thought that "dir" is the path in the IIS working directory, and the page cannot be displayed during running, or the JSP code is not parsed. In fact, this is the path setting problem.
It is worth noting that if "/DIR/" exists in both the IIS and tomcat working directories, the server will connect this path to Tomcat for processing.
When your Tomcat and IIS work normally together, you can modify this file at any time to add a new directory to support JSP running.

Here are more rules about the worker2.properties file.

Right-click the Tomcat Service icon in the system bar and select"Stop Service", Disable the service.

In"Management tools-services"Found"Apache Tomcat"Service, and make sure it has started.



Tomcat IIS Connector

You have placedIsapi_redirector2.dllIn your path, in this example
C:/tomcat 5.0/bin/Win32/i386

Now you need to add some necessary registration information to the Registry, which will be read when redirector is called by IIS. Create a. reg file

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE/software/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.

The result is as follows:

You can see in the registry:

 

Now you can delete this. reg file.


Windows

Add two system environment variables. They areCatalina_homeAndJava_home.

Right-click my computer on the desktop and choose Properties> advanced> environment variable"

Catalina_homePoint to your tomcat installation directory. In this example, C:/tomcat 5.0

Java_homePoint to the Java SDK installation directory. In this example, C:/j2sdk1.4.2 _ 04



Install ISAPI filter in IIS

EnterISAPI filterInterface

ClickAddButton to enter a new filter name.

Click againBrowseButton, selectIsapi_redirector2.dll.In this example
C:/tomcat 5.0/bin/Win32/i386/isapi_redirector2.dll

ClickOK.After IIS is restarted, the new filter will take effect. We will not restart it first and then do it later.

ClickOKSave changes and exit site Properties dialog box.

Note:: You can select a specific site to add a filter or add a filter to all sites.
In the IIS tree, right-click"Computer", Call upAttribute, Select"Edit"Call upPrimary attributeDialog Box

Call upPrimary attributeDialog box, addFilter.



Virtual directory required to create a filter

Select the Tomcat service site to be loaded, right-click and selectNewAnd then selectVirtual directory

Create a virtual directory with the alias:Jakarta. Note that this name is a fixed value. Do not make spelling mistakes!

Specify the directoryIsapi_redirector2.dllDirectory. In this example, C:/tomcat 5.0/bin/Win32/i386

SelectRunTo make it available

After creating a virtual directory, you should see the following in management.

 



Restart the IIS service

SelectComputer, Right-click, selectRestart IIS

SelectReSTART Internet services, Click OK

Operating SystemManagement tools-Event ViewerTo view the service startup status, isapi_redirector2.dll will write its error informationEvent ViewerInstead of writing data to a file as in earlier versions.

On the IIS console,Site PropertiesInISAPIFilterIn the list, you can see the status of the Tomcat Connector, there is a green up arrow on the right



Test Tomcat

First, test whether the tomcat installation example can run. Use the Tomcat server and port.

Servlets: http: // localhost: 8080/Servlets-examples/

JSP: http: // localhost: 8080/JSP-examples/

Test Tomcat Management Interface: http: // 127.0.0.1: 8080/admin/

IIS

Now we access the same example in IIS to test whether the connector works. Note that the modification address and port are consistent with your IIS

Http: // localhost/Servlets-examples/

Http: // localhost/JSP-examples/

 

If everything works properly, you have made iis5 able to parse JSP & servlet programs under Tomcat JK2 IIS connector. Congratulations.
We are happy to get your experience and feedback on this 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.