|
|
Not: Bu yapılandırma örneğinde IIS 5.0 ve Tomcat 4.0.3 kullanılmıştır. IIS ve/veya Tomcat'in farklı versiyonları için işe yaramayabilir.
IIS ve Tomcat kurulumu için hem Tomcat hem de IIS tarafında yapılması gerekenler ayrı başlıklar altında aşağıdaki gibidir:
Tomcat tarafı:
IIS tarafı:
IIS'e gelen Java Servlet/JSP istekleri IIS'e yüklenen bir ISAPI filtresi üzerinden Tomcat'e gönderilir. Bu iş için isapi_redirect.dll isimli bir dosya kullanılır. Bu dosyayı (isapi_redirect.dll) Tomcat'i kurduğunuz dizin altında bin dizinine kopyalamanız gerekir. (Başka bir dizin de tercih edilebilir. Ancak dosyaların ilgili yerlerde bulundurulması açısından bin dizinini tercih etmemizde yarar var.)
isapi_redirect.dll'i ihtiyacı olan yapılandırma değişkenlerine erişmek için Windows Registry'sini kullanır. Bu yüzden bir registry dosyası hazırlayıp bunu Windows Registry' sine eklemek ya da direkt olarak gidip registry'i düzenlemek gerekir. Birincisi nisbeten daha kolay olacağından onu tercih edebiliriz. Bunun için Tomcat'i kurduğumuz dizin altındaki conf dizinine gidip altına jk isminde bir dizin açalım. Dizin ismi olarak jkyı şeçmemizin herhangi bir özel nedeni yok. Kısaca Jakarta ismini ifade ediyor sadece. Daha sonra bu dizin altına diğer yapılandırma dosyalarını da ekleyeceğiz. jk dizini altında iis_redirect.reg isminde bir dosya açarak içerisine şunları yazalım:
Not: Buradaki ${TOMCAT_HOME}'u Tomcat'i kurduğunuz dizin ismi ile değiştirin. (mesela: C:\\Tomcat4IIS gibi.) Ayrıca dizin ayracı olarak \\ kullanmayı unutmayın.
REGEDIT4 [HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Jakarta Isapi Redirector\1.0] "extension_uri"="/jakarta/isapi_redirect.dll" "log_file"="${TOMCAT_HOME}\\logs\\iis_redirect.log" "log_level"="emerg" "worker_file"="${TOMCAT_HOME}\\conf\\jk\\worker.properties" "worker_mount_file"="${TOMCAT_HOME}\\conf\\jk\\uriworkermap.properties"
Dosyayı Windows Registry'sine eklemek için üzerine sağ tuş ile tıklayıp menüden Ekle (Merge)'i seçin.
uriworkermap.properties IIS'e gelen hangi isteklerin Tomcat'e yönlendirilmesi konusunda gerekli bilgileri içerir. Bu dosyayı ilk kurulumda elle üretmemiz gerekir. Bunun için Tomcat'i kurduğumuz dizin altındaki conf dizini altında bir önceki adımda açmış olduğumuz jk dizinine giderek uriworkermap.properties isminde bir dosya üretelim. Dosyaya verdiğimiz ismi farklı seçebiliriz. Ancak registry'de de bu ismi kullandığımızdan dolayı onu da değiştirmek kaydıyla. Bu dosya içerisine şunları yazalım:
# '/servlet' ile başlayan tüm linkleri 'myTomcatWorker' a gönder. /servlet/*=myTomcatWorker # '.jsp' ile biten tüm tüm linkleri 'myTomcatWorker' a gönder. /*.jsp=myTomcatWorker
Tomcat, IIS'den gelen istekleri arkada çalışan worker isimli bir işlem ile çalıştırır. worker.properties dosyası bunun için gerekli yapılandırma değişkenlerinin tanımlandığı yerdir. Bu dosyayı elle üretmemiz gerekir. Bunun için Tomcat'i kurduğumuz dizin altındaki conf dizini altında açmış olduğumuz jk dizinine giderek worker.properties isminde bir dosya üretelim. Dosyaya verdiğimiz ismi farklı seçebiliriz. Ancak registry'de de bu ismi kullandığımızdan dolayı onu da değiştirmek kaydıyla. Bu dosya içerisine şunları yazalım:
# # worker.tomcat_home tomcat'i kurduğunuz dizini göstermeli. Mesela: C:\Tomcat4IIS gibi # worker.tomcat_home={beni-değiştir} # # worker.java_home java platform'unu kurduğunuz dizini göstermeli. Mesela: C:\jdk1.4.0 gibi. # worker.java_home={beni-değiştir} # # Dizinleri ayırmak için kullanılan karakter NT için: \, UNIX için: / # ps=\ # # Tomcat'in kullandığı worker'ların isim listesi. Bizim örneğimizde # bir tane var onu yazmamız gerekir. Birden fazla olduğu durumlarda # virgül (,) ile ayrılır. # worker.list=myTomcatWorker # # worker tipi, portu ve dinleyeceği host isimleri. # Biz bu örnek için sadece ajp13 isimli tip ile ilgileniyoruz. AJP Tomcat ile # web sunucularının konuşurken kullandığı protokol. ajp13 -< AJP v1.3 protokolu # # port numarası daha sonra server.xml'de tanımlayacağımız AJP protokol sunucusunun # istekleri dinlediği port numarası # worker.myTomcatWorker.type=ajp13 worker.myTomcatWorker.port=9009 worker.myTomcatWorker.host=localhost
server.xml dosyası Tomcat'in yapılandırma dosyasıdır. Tomcat'i ilk kurduğunuzda hazırlanmış olarak gelir. Bu adımda Tomcat'in sadece IIS ile çalışması için gerekli ayarları yapacağız. server.xml dosyası Tomcat dizini altındaki conf dizini içerisindedir. Bu dosyayı açıp içeriğini aşağıdaki kısımla değiştirelim:
Göster Gizle Kopar Satır Gizle Satır Göster |
1 Server port="8005" shutdown="SHUTDOWN" debug="0"> 2 <!-- 3 <Listener className="org.apache.ajp.tomcat4.config.IISConfig"/> 4 --> 5 <!-- A "Service" is a collection of one or more "Connectors" that share 6 a single "Container" (and therefore the web applications visible 7 within that Container). Normally, that Container is an "Engine", 8 but this is not required. 9 Note: A "Service" is not itself a "Container", so you may not 10 define subcomponents such as "Valves" or "Loggers" at this level. 11 --> 12 <Service name="Tomcat-With-IIS"> 13 <!-- A "Connector" represents an endpoint by which requests are received 14 and responses are returned. Each Connector passes requests on to the 15 associated "Container" (normally an Engine) for processing. 16 By default, a non-SSL HTTP/1.1 Connector is established on port 8080. 17 You can also enable an SSL HTTP/1.1 Connector on port 8443 by 18 following the instructions below and uncommenting the second Connector 19 entry. SSL support requires the following steps (see the SSL Config 20 HOWTO in the Tomcat 4.0 documentation bundle for more detailed 21 instructions): 22 * Download and install JSSE 1.0.2 or later, and put the JAR files 23 into "$JAVA_HOME/jre/lib/ext". 24 * Execute: 25 %JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA (Windows) 26 $JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA (Unix) 27 with a password value of "changeit" for both the certificate and 28 the keystore itself. 29 By default, DNS lookups are enabled when a web application calls 30 request.getRemoteHost(). This can have an adverse impact on 31 performance, so you can disable it by setting the 32 "enableLookups" attribute to "false". When DNS lookups are disabled, 33 request.getRemoteHost() will return the String version of the 34 IP address of the remote client. 35 --> 36 <!-- Define a non-SSL HTTP/1.1 Connector on port 8080 --> 37 <!-- 38 <Connector className="org.apache.catalina.connector.http.HttpConnector" 39 port="8080" minProcessors="5" maxProcessors="75" 40 enableLookups="true" redirectPort="8443" 41 acceptCount="10" debug="0" connectionTimeout="60000"/> 42 --> 43 <!-- Note : To disable connection timeouts, set connectionTimeout value to -1 --> 44 <!-- Define an SSL HTTP/1.1 Connector on port 8443 --> 45 <!-- 46 <Connector className="org.apache.catalina.connector.http.HttpConnector" 47 port="8443" minProcessors="5" maxProcessors="75" 48 enableLookups="true" 49 acceptCount="10" debug="0" scheme="https" secure="true"> 50 <Factory className="org.apache.catalina.net.SSLServerSocketFactory" 51 clientAuth="false" protocol="TLS"/> 52 </Connector> 53 --> 54 <!-- Define an AJP 1.3 Connector on port 9009 --> 55 <Connector className="org.apache.ajp.tomcat4.Ajp13Connector" 56 port="9009" minProcessors="5" maxProcessors="75" 57 acceptCount="10" debug="0"/> 58 <!-- Define a Proxied HTTP/1.1 Connector on port 8081 --> 59 <!-- See proxy documentation for more information about using this. --> 60 <!-- 61 <Connector className="org.apache.catalina.connector.http.HttpConnector" 62 port="8081" minProcessors="5" maxProcessors="75" 63 enableLookups="true" 64 acceptCount="10" debug="0" connectionTimeout="60000" 65 proxyPort="80"/> 66 --> 67 <!-- Define a non-SSL HTTP/1.0 Test Connector on port 8082 --> 68 <!-- 69 <Connector className="org.apache.catalina.connector.http10.HttpConnector" 70 port="8082" minProcessors="5" maxProcessors="75" 71 enableLookups="true" redirectPort="8443" 72 acceptCount="10" debug="0"/> 73 --> 74 <!-- An Engine represents the entry point (within Catalina) that processes 75 every request. The Engine implementation for Tomcat stand alone 76 analyzes the HTTP headers included with the request, and passes them 77 on to the appropriate Host (virtual host). --> 78 <!-- Define the top level container in our container hierarchy --> 79 <Engine name="Standalone" defaultHost="localhost" debug="0"> 80 <!-- The request dumper valve dumps useful debugging information about 81 the request headers and cookies that were received, and the response 82 headers and cookies that were sent, for all requests received by 83 this instance of Tomcat. If you care only about requests to a 84 particular virtual host, or a particular application, nest this 85 element inside the corresponding <Host> or <Context> entry instead. 86 For a similar mechanism that is portable to all Servlet 2.3 87 containers, check out the "RequestDumperFilter" Filter in the 88 example application (the source for this filter may be found in 89 "$CATALINA_HOME/webapps/examples/WEB-INF/classes/filters"). 90 Request dumping is disabled by default. Uncomment the following 91 element to enable it. --> 92 <!-- 93 <Valve className="org.apache.catalina.valves.RequestDumperValve"/> 94 --> 95 <!-- Global logger unless overridden at lower levels --> 96 <Logger className="org.apache.catalina.logger.FileLogger" 97 prefix="catalina_log." suffix=".txt" 98 timestamp="true"/> 99 <!-- Because this Realm is here, an instance will be shared globally --> 100 <Realm className="org.apache.catalina.realm.MemoryRealm"/> 101 <!-- Replace the above Realm with one of the following to get a Realm 102 stored in a database and accessed via JDBC --> 103 <!-- 104 <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99" 105 driverName="org.gjt.mm.mysql.Driver" 106 connectionURL="jdbc:mysql://localhost/authority?user=test;password=test" 107 userTable="users" userNameCol="user_name" userCredCol="user_pass" 108 userRoleTable="user_roles" roleNameCol="role_name" /> 109 --> 110 <!-- 111 <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99" 112 driverName="oracle.jdbc.driver.OracleDriver" 113 connectionURL="jdbc:oracle:thin:@ntserver:1521:ORCL?user=scott;password=tiger" 114 userTable="users" userNameCol="user_name" userCredCol="user_pass" 115 userRoleTable="user_roles" roleNameCol="role_name" /> 116 --> 117 <!-- 118 <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99" 119 driverName="sun.jdbc.odbc.JdbcOdbcDriver" 120 connectionURL="jdbc:odbc:CATALINA" 121 userTable="users" userNameCol="user_name" userCredCol="user_pass" 122 userRoleTable="user_roles" roleNameCol="role_name" /> 123 --> 124 <!-- Define the default virtual host --> 125 <Host name="localhost" debug="0" appBase="c:/inetpub/wwwroot" unpackWARs="true"> 126 <!-- 127 <Listener className="org.apache.ajp.tomcat4.config.IISConfig" append="true"/> 128 --> 129 <!-- Normally, users must authenticate themselves to each web app 130 individually. Uncomment the following entry if you would like 131 a user to be authenticated the first time they encounter a 132 resource protected by a security constraint, and then have that 133 user identity maintained across *all* web applications contained 134 in this virtual host. --> 135 <!-- 136 <Valve className="org.apache.catalina.authenticator.SingleSignOn" 137 debug="0"/> 138 --> 139 <!-- Access log processes all requests for this virtual host. By 140 default, log files are created in the "logs" directory relative to 141 $CATALINA_HOME. If you wish, you can specify a different 142 directory with the "directory" attribute. Specify either a relative 143 (to $CATALINA_HOME) or absolute path to the desired directory. 144 --> 145 <Valve className="org.apache.catalina.valves.AccessLogValve" 146 directory="logs" prefix="localhost_access_log." suffix=".txt" 147 pattern="common"/> 148 <!-- Logger shared by all Contexts related to this virtual host. By 149 default (when using FileLogger), log files are created in the "logs" 150 directory relative to $CATALINA_HOME. If you wish, you can specify 151 a different directory with the "directory" attribute. Specify either a 152 relative (to $CATALINA_HOME) or absolute path to the desired 153 directory.--> 154 <Logger className="org.apache.catalina.logger.FileLogger" 155 directory="logs" prefix="localhost_log." suffix=".txt" timestamp="true"/> 156 <!-- Define properties for each web application. This is only needed 157 if you want to set non-default properties, or have web application 158 document roots in places other than the virtual host's appBase 159 directory. --> 160 <!-- Tomcat Root Context --> 161 <Context path="" docBase="" debug="0"/> 162 </Host> 163 </Engine> 164 </Service> 165 </Server>
Aşağıdaki kısımda C:/inetpub/wwwroot'u IIS'in sizin kurulumunuzdaki web kök dizini ile değiştirin.
<!-- Define the default virtual host --> <Host name="localhost" debug="0" appBase="c:/inetpub/wwwroot" unpackWARs="true">
Böylece Tomcat'e Java Servlet ve JSP'lerini IIS'in web kök dizini içerisinde arayacaktır.
Not: Bunu mevcut server.xml üzerinde bir kısım değişiklikler yaparak da elde etmek mümkündür. Zaten dikkat edilirse içeriğin çoğunluğu aynıdır. Fakat burada açıklanmasının kafa karıştırabileceğini düşündüğümden hazır halini veriyorum
Tomcat'i Windows NT/2K servisi olarak ayarlayabiliriz. Böylece makine açılır açılmaz Tomcat'in çalışması sağlanabilir. Tomcat'i kurduğumuz dizin altında bin dizininde bir betik dosyası hazırlayıp bunu çalıştırarak Tomcat'i servis olarak yükleyebiliriz. Aynı şekilde servis olarak eklediğimiz Tomcat'i Windows NT/2K servisleri arasından çıkarabiliriz.
Eklemek için:
inst-as-service.bat isminde bir dosya üretin ve içine şunları yazın:
set TOMCAT_HOME=c:\tomcat4iis "%TOMCAT_HOME%\bin\tomcat.exe" -install Tomcat "%JAVA_HOME%\jre\bin\server\jvm.dll" -Djava.class.path="%TOMCAT_HOME%\bin\bootstrap.jar;%JAVA_HOME%\lib\tools.jar" -Dcatalina.home="%TOMCAT_HOME%" -start org.apache.catalina.startup.BootstrapService -params start -stop org.apache.catalina.startup.BootstrapService -params stop -out "%TOMCAT_HOME%"\logs\stdout.log -err "%TOMCAT_HOME%"\logs\stderr.log
Çıkarmak için:
uninst-service.bat isminde bir dosya üretin ve içine şunları yazın:
set TOMCAT_HOME=c:\tomcat4iis "%TOMCAT_HOME%\bin\tomcat.exe" -uninstall Tomcat
IIS'e gelen Java Servlet ve JSP isteklerinin Tomcat'e yönlendirilmesi için gerekli olan isapi_redirect.dll dosyasından bahsetmiştik. Şimdi bu dll'i IIS'e tanıtmamız gerekir. Öncelikle IIS servislerini kapatmamız gerekir. Sonra IIS'in yönetim konsolunu açalım. Windows 2000 Professional'da konsola Denetim Masası (Control Panel), Yönetim Araçları (Administrative Tools), Internet Servisleri Yönetimini (Internet Services Management) açın.
*<makine-ismi> isimli imgeye sağ tuş ile tıklayıp, Özellikler (Properties) menüsünü seçin.
Buradan Ana Özellikler'den (Master Properties) WWW Servisi (WWW Service) seçili iken Düzenle (Edit) butonuna tıklayın.
ISAPI Filtreleri (ISAPI Filters) kısmına geçip, Ekle (Add) butonuna basın.
Karşınıza çıkan pencereden Filtre İsmi (Filter Name) olarak Jakarta girin. Çalıştırılabilir dosya alanına isapi_redirect.dll ini dizin isimleri ile beraber girin veya seçin. Bu dosyayı tomcat'i kurduğunuz dizinin altında bin dizinine kopyalamıştık.
Yapılan değişiklikleri onaylayarak pencerelerden çıkın. Bu değişikliğin aktif hale gelebilmesi için IIS servisini başlatmanız yeterlidir. Bazı durumlarda makineyi yeniden başlatmak gerekebilir. IIS tekrar başladığında tekrar ISAPI filtreleri kısmına gittiğinizde yeni eklediğiniz filtrenin yanında yukarı doğru yeşil bir ok göreceksiniz.
Hoşgeldin sayfaların web sunucusunun kök dizininde bir dizin isteği geldiğinde sunulacak ilk dosyadır. Mesela: index.html gibi. Doğal olarak IIS .jsp ile biten dosyaları hoşgeldin sayfası olarak kabul etmez. Bunun için yukarıda olduğu gibi IIS'in yönetim konsolundan Ana Özellikler'den (Master Properties) WWW Servisi (WWW Service) düzenleme ekranına gidin.
Buradan Dokümanlar (Documents) kısmına geçip yeni bir hoşgeldin sayfası eklemek için Ekle (Add) butonuna basın.
Karşınıza çıkan pencerede dosya ismi olarak index.jsp girin.
Yapılan değişiklikleri onaylayarak pencerelerden çıkın.
|
|