Integrate IIS and tomcat (configuration method for sharing port 80)

Source: Internet
Author: User

1. Preparations
1. Open the IIS service and enter http: // localhost in the address bar of the browser to confirm that the IIS service is normal.

2. Open the Tomcat service and enter http: // localhos: 8080 in the address bar of the browser to confirm that the Tomcat service is normal.

(Note: there may be no tools. jar package under the [tomcat] commonlib directory, so you must copy it)

3. Download the bridge between IIS and Tomcat. The address is as follows:

Http://apache.justdn.org/tomcat/tomcat-connectors/jk2/binaries/win32/

2. TOMCAT configuration

1. decompress the downloaded jakarta-tomcat-connectors-jk2.0.4-win32-iis.zip. Copy the isapi_redirector2.dll file under the bin directory to any directory. However, we recommend that you create an iis directory under tomcat and copy it to this directory.

2. Create a registration file under the iis directory with any file name (easy to see). The purpose of this file is to register this dll into the system file. the registration file content is as follows. (assume that Tomcat 5 is installed under d: omcat5)

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINESOFTWAREApache Software FoundationJakarta Isapi Redirector2.0]

"ServerRoot" = "d: \ tomcat5"

"ExtensionUri" = "/jakarta/isapi_redirector2.dll"

"WorkersFile" = "d: \ tomcat5 \ conf \ workers2.properties"

"LogLevel" = "INFO"

After entering the above file, double-click to register the dll file. (Note: if the registration fails, the registration file must have been written incorrectly .)

 

3. Now configure the workers2.properties file used in the above registration file. Write this file and put it under the d: omcat5conf directory.

[Shm]

File = d:/tomcat5/logs/jk2.log

Size = 1048576

# Replace all localhost and 8009 with your own IP address and port.

[Channel. socket: localhost: 8009]

Port = 8009

Host = localhost

# Define the worker

[Ajp13: localhost: 8009]

Channel = channel. socket: localhost: 8009

# Uri mapping

[Uri:/*. jsp]

[Uri:/iistest/*]

 

The Uri mapping here is the most important thing. It is related to whether IIS5 and tomcat5 can work together,

Note:

[Uri:/*. jsp] indicates the type of file to be parsed,

[Uri:/iistest/*] is used to configure virtual hosts in the server. xml file.

 

4. Configure the jk2.properties file. The file is also in the conf directory and the content is as follows:

 

# 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

# Channel socket. port = 8019

# Default:

# ChannelUnix. file =$ {jkHome}/work/jk2.socket

# Just to check if the config is working

# Shm. file =$ {jkHome}/work/jk2.shm

# In order to enable jni use any channelJni direve ve

# ChannelJni. disabled = 0

# And one of the following ctictives:

# 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

Request. tomcatAuthentication = false

 

All the above # numbers are originally available in tomcat 5. What we need to add is the last sentence. This sentence indicates whether the request needs to be verified on the tomcat server.

 

5. Now let's Configure the server. xml file and the web. xml file.

In step 3, we have already mentioned [uri:/iistest/*]. What is it?

It is very important that this is related to the ing between IIS and tomcat. Let's take a look at how to configure it in the server. xml file.

What I want to talk about now is to build my own virtual host, instead of placing the developed file package under the tomcat webapp directory. Therefore, I need to configure a host by myself. The configuration method is as follows:

Find the original server. xml file </Host> and add your own virtual host after the Host.

<Host name = "www. ecai. biz" debug = "0" appBase = "webapps"

UnpackWARs = "true" autoDeploy = "true"

XmlValidation = "false" xmlNamespaceAware = "false">

 

<Logger className = "org. apache. catalina. logger. FileLogger"

Directory = "www. eca. biz. logs" prefix = "www_ecai_biz_log." suffix = ". txt"

Timestamp = "true"/>

 

<Context path = "/iistest" docBase = "D: iistest" debug = "0"

Reloadable = "true" crossContext = "true">

</Context>

</Host>

All of the above are important, but the most important thing in the article about how to work together iis and tomcat is <Context path. Note, our path = "/iistest" is consistent with the uri mapping in the worker2.properties file .. be sure to note that this is the most critical link.

The following describes how to modify the web. xml file.

Find the invoker in web. xml,

Modify 1

<! -- <Servlet>

<Servlet-name> invoker </servlet-name>

<Servlet-class>

Org. apache. catalina. servlets. InvokerServlet

</Servlet-class>

<Init-param>

<Param-name> debug </param-name>

<Param-value> 0 </param-value>

</Init-param>

<Load-on-startup> 2 </load-on-startup>

</Servlet> -->

By default, this comment is commented out.

 

Modify 2

<! -- <Servlet-mapping>

<Servlet-name> invoker </servlet-name>

<Url-pattern>/servlet/* </url-pattern>

</Servlet-mapping> -->

Remove comments

Okay, the above is what needs to be modified in tomcat. After the modification is complete, open your tomcat and test whether the configured virtual host is running normally.

Jsp "> http://www.ecai.biz: 8080/iistest/index. jsp

If the above operation is normal, it indicates that the virtual host is successfully configured. Next we need to configure it in iis.

3 IIS5 Configuration

1. ISAPI filter configuration

& Nb

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.