发布时间:2017-04-25 来源:服务器之家
因为公司之前的程序是用编写,现在部分程序需要用java语言开发。因此需求来了,就是当iis遇到jsp请求时能将请求转发给tomcat编译。我花了一些时间在win7和win2003/winXP系统中都整合成功了,都达到了我要的目的。具体教程如下:
1.WindowsServer2003/XP系统下iis6和tomcat6的整合。
软件环境:
win2003/winXP
jdk1.6
tomcat6.0
iis6
JK isapi_redirect-版本号.dll
1.安装IIS
控制面板--> 添加删除程序 --> 添加删除windows组件
2.测试IIS
3.安装java环境,配置环境变量,具体不赘述。
4.安装tomcat (安装版和解压缩版都ok)
启动tomcat
测试8080端口
5.基本工作完成 下面我们进行整合
一路next
安装目录是
C:\Program Files\Apache Software Foundation\Jakarta Isapi Redirector
选中其中的jakarta的虚拟目录,并查看属性中 是否存在jakarta的筛选器。至于向上的绿色箭头可能没有只要不是红色就可以。
别名 jakarta (必须) 路径 C:\Program Files\Apache Software Foundation\Jakarta Isapi Redirector\bin\
如果已经存在了jkarta筛选器,则a,b两个步骤省略。
7.配置访问权限
# uriworkermap.properties - IIS
#
# This file provides sample mappings for example wlb # worker defined in workermap.properties.minimal # The general syntax for this file is:# [URL]=[Worker name]
/admin/*=wlb
/manager/*=wlb
/jsp-examples/*=wlb
/servlets-examples/*=wlb
# Optionally filter out all .jpeg files inside that context # For no mapping the url has to start with exclamation (!)!/servlets-examples/*.jpeg=wlb
#
# Mount jkstatus to /jkmanager # For production servers you will need to # secure the access to the /jkmanager url#
/jkmanager=jkstatus
/0431la/*=wlb
/0431la/*的意思是当路径中包涵/04311a/时所有的请求转发给tomcat容器处理。接下来我们可以进行测试
ok了 虽然这不是我们的最终结果 但是至少我们之前配置的没有问题了
下面我们进行虚拟主机的配置
9.我们把0431la目录放到c盘根目录并配置tomcat的虚拟主机
<Host name="www.0431.la" debug="0" appBase="c:\0431la" unpackWARs="true" autoDeploy="true">
</Host>
10.在iis下面配置虚拟主机的映射目录11.修改配置文件
C:\Program Files\Apache Software Foundation\Jakarta Isapi Redirector\conf\uriworkermap.properties
# uriworkermap.properties - IIS
#
# This file provides sample mappings for example wlb # worker defined in workermap.properties.minimal # The general syntax for this file is:# [URL]=[Worker name]
/admin/*=wlb
/manager/*=wlb
/jsp-examples/*=wlb
/servlets-examples/*=wlb
# Optionally filter out all .jpeg files inside that context # For no mapping the url has to start with exclamation (!)!/servlets-examples/*.jpeg=wlb
#
# Mount jkstatus to /jkmanager # For production servers you will need to # secure the access to the /jkmanager url#
/jkmanager=jkstatus
/0431la/*=wlb
以上配置目的是让jsp请求交由tomcat处理重启iis 和 tomcat 看看我们的成果
我们可以发现jsp请求完全正常解析了。
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>
<head>
<base href="http://jdfkldjlkjdl/article/details/<%=basePath%>"> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"><!--
<link rel="stylesheet" type="text/css" href="http://jdfkldjlkjdl/article/details/styles.css">-->
</head>
<body>
This is my JSP page. <br></body>
</html>
该jsp是myeclipse工程自动生成的。isapi_redirect-1.2.14.dll下载
该教程参考的帖子:
2.Windows7系统下iis7和tomcat6的整合。
需要的软件资源
1.win7 64位 (我当时用的系统环境,32位原理相同)
2.jdk1.6
3.tomcat6.0
4.JK isapi_redirect-版本号.dll
整合步骤如下:
说明:在win2003和winXP中使用的是安装JK isapi_redirect-版本号.dll的方式,下面使用手工配置的方式在win7下实现iis7+tomcat6的整合。
现在开始:
注:{tomcat_home}为tomcat安装目录。
1. 在{tomcat_home}/conf下建立workers.properties文件,内容如下:
# worker.list的值为对应的tomcat的值
worker.list=geloinWorker
# tomcat的server.xml中有<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />,以下的三个值分别对应这里的属性worker.geloinWorker.type=ajp13
worker.geloinWorker.host=localhost
worker.geloinWorker.port=8009
2. 在{tomcat_home}/conf下建立uriworkermap.properties文件,内容如下:
# 重定向规则,以下意思为“当网页地址为....../examples/...”时重写向到workers.properties中规定的tomcat中/examples/*=geloinWorker
extension_uri=/jakarta/isapi_redirect.dll log_file=d:/work/download/apache-tomcat-6.0.33/logs/isapi_redirect.loglog_level=info
worker_file=d:/work/download/apache-tomcat-6.0.33/conf/workers.properties worker_mount_file=d:/work/download/apache-tomcat-6.0.33/conf/uriworkermap.properties 注意:该处所指的所有文件,例如isapi_redirect.log,workers.properties ,uriworkermap.properties都是手工创建的, 都必须创建后再在isapi_redirect.properties中进行配置。4. 在“Default Web Site”下添加“ISAPI”筛选器,可执行文件为{tomcat_home}/jk/isapi_redirect.dll:
5. 右键点击“Default Web Site”,建立虚拟目录“jakarta”(必须为此名字),目标地址指向{tomcat_home}/jk:
6. 点击“jakarta”,在功能视图中找到“处理映射程序”并双击之,在右侧找到编辑功能权限,全部选中:
7. 点击计算机名,在功能视图中找到“ISAPI和CGI限制”,双击之:
8. 在右侧找到“添加”,添加ISAPI和CGI限制,路径为isapi_redirect.dll的路径:
至此,iis和tomcat整合完毕,接下来可使用iis访问jsp页面,不过需要提示的是,请注意uriworkermap.properties中设定的重定向规则,只有符合规则的网页才会被重定向到tomcat中。
比如现在在tomcat webapps下面有个项目springmvc001,则uriworkermap.properties中配置如下:
/springmvc001/*=geloinWorker
特别注意转发规则的配置,因为如果没有配置好转发规则,jsp项目图片等静态资源无法访问。
常见配置规则说明:
uriworkermap.properties# 当前域名下的所有请求都转发给geloinWorker工作站处理
# /*=geloinWorker
参考文章