Simplest configuration for Windows IIS + JK + Tomcat. [reprint]

Reprint address: http://www.oschina.net/question/17_2491

 

Recently researched a lot of things under Windows.
There should be a lot of articles about IIS + JK + tomcat configuration on the Internet. I mainly want to simplify the complexity and share the easiest method for novices.

I personally disdain IIS, but to a certain extent it is indeed the most powerful httpd server for Windows. The version of apache and Nginx for windows will have a limit of 200 threads, only IIS does not. And if you have an asp application, with a server, you can't choose.

It's very simple. In fact, it's just a few steps, and you don't need to click the mouse many times to elaborate.
First we have to prepare the required software:

1. Download and install JDK (as of press time, the latest version is 6U16)

Update release URL: http://java.sun.com/javase/downloads/index.jsp
JDK 6U16 download URL: https://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer- Site/en_US/-/USD/ViewProductDetail-Start?ProductRef=jdk-6u16-oth-JPR@CDS-CDS_Developer

2. Download and install tomcat 6 (as of press time, the latest version is 6.0.20)
(Windows Service Installer) This version can complete the tomcat + JDK environment in the installation wizard, and exists in Windows as a service.

Update release URL: http://tomcat.apache.org/download-60.cgi
Tomcat 6.0.20 Download URL: http://apache.freelamp.com/tomcat/tomcat-6/v6.0.20/bin/apache- tomcat-6.0.20.exe

3. Download JK For IIS ISAPI filter (as of press time, the latest version of JK is 1.2.28)

Update release URL: http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/win32/
JK ISPI 1.2.28 Download: http://archive.apache.org/dist/tomcat/tomcat -connectors/jk/binaries/win32/jk-1.2.28/isapi_redirect-1.2.28.dll

 

Next, start integrating the above things into IIS

1. Complete the installation of JDK and tomcat. The steps are quite simple.
In order, install JDK first. After completion, there will be two folders in the installation directory, namely JDK and JRE.
Then when installing tomcat, you will be asked to select the path of the JRE, which corresponds to the path of the JRE above.

Others are not detailed. But the configuration of tomcat needs to be written.

To simplify the complexity, delete the contents of conf/server.xml in the tomcat installation directory, and then change it to:

<Server port="8005" shutdown="SHUTDOWN">
  <Service name="Catalina">
    <Connector port="8081" protocol="org.apache.coyote.http11.Http11NioProtocol"
                connectionTimeout="20000"
                        redirectPort="8443" />
    <Connector port="8009" maxThreads="1000" protocol="AJP/1.3" redirectPort="8443"/>
    <Engine jvmRoute="tomcat1" name="Catalina" defaultHost="localhost">
      <Host name="localhost"  appBase="webapps"
            unpackWARs="false" autoDeploy="false"
            xmlValidation="false"xmlNamespaceAware="false">
        <Context path="" docBase="D:\web_server\java" reloadable="false"/>
     </Host>
    </Engine>
  </Service>
</Server>

 

In fact, you can also modify the original file according to the above parameters.
Then note that <Connector port="8009" maxThreads="1000" protocol="AJP/1.3" redirectPort="8443"/> and
<Context path="" docBase="D:\web_server\java" reloadable= "false"/>

These two lines respectively set the communication port of JK and the directory where the application is located.

2. Create 2 configuration files for JK. They are  workers.properties  and uriworkermap.properties

Contents of workers.properties  (remove comments for practical application):

////////////////////////////////////////////////////////////////////////////////////

workers.tomcat_home=D:\Tomcat 6.0 //Corresponding to the installation path of tomcat
workers.java_home=C:\Program Files\Java\jdk1.6.0_16 //Corresponding to the installation path of JDK

worker.list=my_tomcat //Application name, you can start it arbitrarily, but after modification, you need to modify the following remaining characters at the same time.

worker.s1.type=ajp13            //通信协议
worker.s1.host=127.0.0.1      //tomcat的IP地址,这里是本机。
worker.s1.port=8009             //tomcat跟JK 的通信端口
worker.s1.lbfactor=1             //用于均衡负载时的配额

#############################

worker.my_tomcat.type=lb     //运行模式,无需修改
worker.my_tomcat.balance_workers=s1   //应用所包含的成员多个可用“,”号隔开。无需修改
worker.my_tomcat.sticky_session=True   //session 粘贴。无需修改

//往下是环境配置,无需修改。

worker.inprocess.class_path=$(workers.tomcat_home)$(ps)classes
worker.inprocess.class_path=$(workers.tomcat_home)$(ps)lib$(ps)jasper.jar
worker.inprocess.class_path=$(workers.tomcat_home)$(ps)lib$(ps)servlet.jar
worker.inprocess.class_path=$(workers.tomcat_home)$(ps)lib$(ps)webserver.jar
worker.inprocess.class_path=$(workers.java_home)$(ps)lib$(ps)tools.jar
worker.inprocess.cmd_line=-config
worker.inprocess.cmd_line=$(workers.tomcat_home)/conf/server.xml
worker.inprocess.cmd_line=-home
worker.inprocess.cmd_line=$(workers.tomcat_home)
worker.inprocess.jvm_lib=$(workers.java_home)$(ps)jre$(ps)bin$(ps)classic$(ps)jvm.dll
worker.inprocess.stdout=$(workers.tomcat_home)$(ps)inprocess.stdout
worker.inprocess.stderr=$(workers.tomcat_home)$(ps)inprocess.stderr
worker.inprocess.sysprops=tomcat.home=$(workers.tomcat_home)

////////////////////////////////////////////////////////////////////////////////////

uriworkermap.properties 的内容(实际应用时请删除注释):

////////////////////////////////////////////////////////////////////////////////////

/*=my_tomcat         

//所有请求发往应用 my_tomcat 以下的除外,因为以下的是静态文件,由IIS处理。

!/*.gif=my_tomcat
!/*.jpg=my_tomcat
!/*.png=my_tomcat
!/*.html=my_tomcat
!/*.htm=my_tomcat
 

//更多静态文件类型由你们自己添加了。

////////////////////////////////////////////////////////////////////////////////////

 

3,开始 JK 与 IIS 整合。

首先把刚才下载的 JK For IIS  ISAPI过滤器 复制到 tomcat\bin\win32 目录下(没有该目录可以创建)

然后开始 IIS 的设置:

1.  启动Internet服务管理器,首先把该站点的目录路径改为java 程序的路径,对应 tomcat 的docBase 路径 如下图所示:

 

1.  新建虚拟目录jakarta

选择默认WEB站点,点击鼠标右键选择新建虚拟目录如下图所示:

         在新增虚拟目录对话框中输入jakarta,选择isapi_redirect.dll所在的目录,给该虚拟目录赋予可执行权限如下图:

 

 

3.  创建ISAPI筛选器

右击默认WEB站点选择属性打开WEB站点的属性对话框并选择ISAPI筛选器如下图:

 

 

点击新建按钮打开新建筛选器对话框,输入筛选器名称jakarta以及isapi_redirect.dll的绝对路径并确定。

 

 

4,然后倒入一份注册表的配置,内容如下(实际应用时请删除注释):

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Jakarta Isapi Redirector\1.0]
"extension_uri"="/jakarta/isapi_redirect.dll"                                         // 对应IIS jakarta虚拟目录的路径
"log_file"="D:\\Tomcat 6.0\\logs\\iis_redirect.log"                                //日志文件路径,用于除错
"log_level"="info"
"worker_file"="D:\\Tomcat 6.0\\conf\\workers.properties"                  //workers.properties 配置文件路径
"worker_mount_file"="D:\\Tomcat 6.0\\conf\\uriworkermap.properties"         //uriworkermap.properties 配置文件路径

创建一个 jk.txt 文档,把以上内容复制进去,然后改名为jk.reg 双击后导入即可。

5.  重新启动IIS

a.       停止默认WEB站点

b.       启动TOMCAT服务器

c.       重新启动服务:World Wide Web Publishing Service

请重新打开图4对话框查看刚添加的筛选器的运行状态,必须有一个绿色向上的箭头。

d.       启动默认WEB站点

然后试试在目录下创建一个 hello.jsp 的程序,看看在浏览器中能否显示出内容。

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326710015&siteId=291194637