大家都了解在ms家族中iis作為internet服務(wù)器可謂是赫赫有名,簡(jiǎn)單,方便。
而且相關(guān)的web程序(asp,asp.net)也是比比皆是。
我們希望java開發(fā)的web程序可以和iis共存(共同使用80端口發(fā)布)。
這方面的教程網(wǎng)上很多,多數(shù)是copy之后又copy,以至于有些細(xì)節(jié)一直含糊不清,也導(dǎo)致我走了許多彎路。在此留個(gè)腳印防止日后的錯(cuò)誤。
軟件及環(huán)境
windows server 2003
iis 6.0
tomcat 6.0.20
jdk 6.0
jk isapi_redirect-1.2.14 (很多情況下是由于isapi_redirect 的版本不符,我之前用過(guò)最新的1.2.28但是沒(méi)有整合成功 大家可以嘗試一下,這個(gè)軟件好像不太好找,服務(wù)器之家為大家提供了,速度更快)
1.安裝iis
控制面板--> 添加刪除程序 --> 添加刪除windows組件
測(cè)試
2.安裝java環(huán)境,這里要用jdk而不是jre
我安裝到
c:\java\jdk1.6
不要忘記配置環(huán)境變量
3.安裝tomcat
我的安裝目錄是
c:\tomcat6
啟動(dòng)tomcat
測(cè)試8080端口
4.基本工作完成 下面我們進(jìn)行整合
安裝isapi_redirect-1.2.14 當(dāng)然也可以直接使用isapi_redirect-1.2.14.dll + 配置文件手動(dòng)編寫,不過(guò)對(duì)于首次安裝還是建議使用安裝文件,防止配置文件書寫產(chǎn)生誤差導(dǎo)致整合不成功。
一路next
安裝目錄是
c:\program files\apache software foundation\jakarta isapi redirector
5.打開iis的管理界面
查看默認(rèn)站點(diǎn)是否存在
中的jakarta的虛擬目錄
并查看屬性中
是否存在jakarta的篩選器。至于向上的綠色箭頭可能沒(méi)有(網(wǎng)上很多都指出要求由此,實(shí)際上只有配置之后首次訪問(wèn)的時(shí)候,才進(jìn)行加載)只要不是紅色就可以。
如果沒(méi)有則創(chuàng)建,
添加篩選器 名稱jakarta 文件地址 c:\program files\apache software foundation\jakarta isapi redirector\bin\isapi_redirect.dll
創(chuàng)建虛擬目錄
別名 jakarta (必須) 路徑 c:\program files\apache software foundation\jakarta isapi redirector\bin\
訪問(wèn)權(quán)限
不要忘記 運(yùn)行腳本 執(zhí)行 勾選
ok
8.我們?cè)趖omcat app下面隨便建立個(gè)工程 我這里是目錄名0431la
修改配置文件
c:\program files\apache software foundation\jakarta isapi redirector\conf\uriworkermap.properties
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# 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 |
我們重啟tomcat 和 iis 并訪問(wèn)測(cè)試
iis的重啟可以通過(guò)鼠標(biāo)右鍵我的電腦 --> 管理 進(jìn)行重啟
接下來(lái)我們可以進(jìn)行測(cè)試
ok了 雖然這不是我們的最終結(jié)果 但是至少我們之前配置的沒(méi)有問(wèn)題了
下面我們進(jìn)行虛擬主機(jī)的配置
9.我們把0431la目錄放到c盤根目錄并配置tomcat的虛擬主機(jī)
<host name="www.0431.la" debug="0" appbase="c:\0431la" unpackwars="true" autodeploy="true">
<context path="" docbase="c:\0431la" debug="0" reloadable="true"/>
</host>
10.在iis下面配置虛擬主機(jī)的映射目錄
并添加jakarta虛擬目錄 和 isapi篩選 配置過(guò)程可參考第五步
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=wlb
讓jsp請(qǐng)求交由tomcat處理
呵呵
重啟iis 和 tomcat 看看我們的成果
我們可以考但jsp請(qǐng)求完全正常解析了。
<%@ 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="<%=basepath%>" rel="external nofollow" >
<title>my jsp 'index.jsp' starting page</title>
<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="styles.css" rel="external nofollow" >
-->
</head>
<body>
this is my jsp page. <br>
</body>
</html>
該jsp是myeclipse工程自動(dòng)生成的。