Windwos 2008 64 IIS7+多tomcat6完美配置

1,在D盤跟目錄建個tomcat_server目錄,結構如下

:

其中tomcat1的server.xml爲

<?xml version='1.0' encoding='utf-8'?>
<Server port="8005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <Listener className="org.apache.catalina.core.JasperListener" />
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <GlobalNamingResources>
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>
  <Service name="Catalina">
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
 <Engine name="Catalina" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>
      <Host name="localhost" appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
      </Host>
    </Engine>
  </Service>
</Server>

其中tomcat2的server.xml爲

<?xml version='1.0' encoding='utf-8'?>
<Server port="8006" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <Listener className="org.apache.catalina.core.JasperListener" />
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <GlobalNamingResources>
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>
  <Service name="Catalina">
    <Connector port="8081" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    <Connector port="8010" protocol="AJP/1.3" redirectPort="8443" />
    <Engine name="Catalina" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>
      <Host name="localhost" appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
      </Host>
    </Engine>
  </Service>
</Server></span>

2,tomcat_server目下建立workers.properties文件,內容如下:

worker.list=tomcat1,tomcat2
worker.tomcat1.port=8009
worker.tomcat1.host=localhost
worker.tomcat1.type=ajp13
worker.tomcat1.lbfactor=1
worker.tomcat2.port=8010
worker.tomcat2.host=localhost
worker.tomcat2.type=ajp13
worker.tomcat2.lbfactor=1

3,tomcat_server目下建立uriworkermap.properties文件,內容如下:

# 當前域名下的所有請求都轉發給ajp13w工作站處理
/www.xxx.com/*=tomcat1
/www.xxx2.com/*=tomcat2

4,tomcat_server目下建立tomcat_IIS.reg文件,然後雙擊運行,內容如下(注意:我這裏是64位的操作系統,要是32位去掉Wow6432Node路徑):

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Apache Software Foundation\Jakarta Isapi Redirector\1.0]
"extension_uri"="/jakarta/isapi_redirect-1.2.27.dll"
"log_file"="E://tomcat_server//isapi.log"
"log_level"="debug"
"worker_file"="E://tomcat_server//workers.properties"
"worker_mount_file"="E://tomcat_server//uriworkermap.properties"

5,在IIS管理器中的“ISAPI和CGI限制”裏面右鍵添加isapi_redirect.dll,並設定“允許執行擴展路徑”,描述名可取jakarta (isapi_redirect.dll文件可以去網上下載



6,在Default Web Site上右鍵添加虛擬目錄,別名可取jakarta,路徑指向tomcat_server目錄,即isapi_redirect.dll所在目錄。


7,接着單擊Default Web Site,選擇ISAPI篩選器,並右鍵添加篩選器,名稱可取jakarta,可執行文件選擇isapi_redirect.dll。





8,然後點擊jakarta虛擬目錄,雙擊“處理程序映射”選擇“編輯功能權限...”將所有權限選上 





9,然後重啓IIS,啓動tomcat  

**由於在uriworkermap.properties文件裏配置了/www.resinfo.com.cn/*=tomcat1 ,所以直接訪問resinfo.com.cn的請求不會被tomcat獲取,需要301重定向
下載rewrite_x64_zh-CN.msi ,是微軟提供的URL重寫組件,安裝成功後在IIS中會出現



然後編輯Default Web Site的web.config文件, 添加如下代碼

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
 <rewrite>
  <rules>
    <rule name="Resinfo域名 301重定向" patternSyntax="Wildcard" stopProcessing="true">
    <match url="*" />
    <conditions>
    <add input="{HTTP_HOST}" pattern="resinfo.com.cn" />
    </conditions>
    <action type="Redirect" url="http://www.resinfo.com.cn/{R:0}" />
    </rule>
  </rules>
 </rewrite>
</system.webServer>
</configuration>

其實上述內容完全在URL重寫模塊填寫,我由於不太熟悉怎麼配置,直接手寫了.







完美解決 


發佈了17 篇原創文章 · 獲贊 6 · 訪問量 7萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章