Due to various reasons, I will re-open my personal blog. You are welcome to come to exchange.
Name: bbbear's blog - persistence
Domain name: www.bbbear.org
Author environment:
Windows 2000 SP4 IIS 5.0 JDK 1.4.2 (I believe that IIS6.0 should also be able to make a problem, if you have problems installed on Windows 2003, please contact me, Netfaery @ 163.com)
Tomcat Installation Path: C: / Tomcat 5.0
JDK1.4 installation path: c: /j2sdk1.4.1_02
Java_Home: C: /J2SDK1.4.1_02
ClassPath:.;% Java_home% / lib / Tools.jar;% java_home% / lib / dt.jar;
Preparation:
Before the integration, the author has assumed that you have successfully installed JDK1.4.2 (now Sun has released JDK5.0, here I only take JDK1.4.2 as an example, because what JDK is used, does not affect the configuration of the server, JDK The role is to play in IIS has played the HTTP request to Tomcat, so wait for your complete configuration of your server, reinstalling higher JDK, there will be no big problem.) And configure Java_Home And ClassPath environment variables.
1. Install Tomcat5.0
The installation mode does not need Normal, but to select FULL (this will be installed to the service mode, and there is Tomcat source code), and then follow the prompts. My Tomcat is installed under C: / Tomcat 5.0, the installation path You can set it it, but if you modify the installation directory, then the corresponding directory of the configuration file you introduced later will have to modify it.
2. Set environment variable tomcat_home
Right-click "Properties" on the "My Computer" icon on the desktop -> "Advanced" -> Environment Variables "->" System Variable "-> New Variable Name: Tomcat_Home, Variable Value: C: / Tomcat 5.0, Click "OK" to save.
3. Copy Isapi_Redirector2.dll
Create a "JK2" folder under C: / Tomcat 5.0 / Conf (this directory you can set it it, but this will affect the parameters of the back-related profile), then copy ISAPI_Redirector2.dll to C: / Tomcat 5.0 / Conf / JK2 below.
4. Create workers2.properties
Create Workers2.Properties to C: / Tomcat 5.0 / Conf, the contents of the file are as follows:
[SHM]
FILE = C: / Tomcat 5.0 / logs / jk2.log
SIZE = 1048576
# Example Socket Channel, Override Port and Host.
[Channel.socket: Localhost: 8009]
Port = 8009
Host = 127.0.0.1
# Define the worker
[AJP13: Localhost: 8009]
Channel = CHANNEL.SOCKET: Localhost: 8009
# Uri mapping
[URI: / *. jsp]
[URI: / servlets-example / *]
Worker = ajp13: Localhost: 8009
# Define the worker
[status: status]
# Uri mapping
[URI: / jkstatus / *]
Worker = status: status
Change the second line of the file before use to change the C: / Tomcat 5.0 of C: File = C: / Tomcat 5.0 / logs / jk2.log into your Tomcat installation path.
5. Create JK2.Properties
Create JK2.Properties to C: / Tomcat 5.0 / Conf. The content is as follows:
## This file may be overriden at runtime. Make sure tomcat is stock
## w edit the file.
## Comments Will Be _lost_
## documentation of the format in jkmain javadoc.
# Set the desired handler list
# Handler.list = Apr, Request, Channeljni
#
# Override The Default Port for the SocketChannel
# channelsocket.port = 8019
# Default:
# channelunix.file = $ {jkhome} /work/jk2.socket
# Just to Check if The config is working
# Shm.file = $ {jkhome} /work/jk2.shm
# In Order To Enable Jni Use Any Channeljni Directive
# channeljni.disabled = 0
# And one of the backing directives:
# apr.jnimodeso = / opt / apache2 / modules / mod_jk2.so
# I set to inprocess the mod_jk2 will register native itself
# This will enable the starting of the tomcat from mod_jk2
# apr.jnimodeso = inprocess
# Request.tomcatauthentication = True
Request.tomcatauthentication = false
6. Create and import registry file ISAPI_Redirect.2.0.Reg
Create and import registry files ISAPI_REDIRECT.2.0.Reg, the content is as follows:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE / SOFTWARE / APACHE SOFTWARE FOUNDATION / JAKARTA Isapi Redirector]
[HKEY_LOCAL_MACHINE / SOFTWARE / APACHE SOFTWARE FOUNDATION / JAKARTA ISAPI Redirector / 2.0]
"ServerRoot" = "c: // Tomcat 5.0"
"eXtensionuri" = "/ jakarta / isapi_redirector2.dll"
"workersfile" = "c: // Tomcat 5.0 // conf // workers2.properties"
"Loglevel" = "debug"
Please modify the registry file before importing, replace the ServerRoot and WorkersFile "C: // Tomcat 5.0" into your Tomcat installation path. 7. Set IIS's ISAPI Filter
Click the Start Menu -> Settings -> Control Panel -> Administrative Tools -> Internet Service Manager, then find your site (my computer name is BBBEAR, "Default Web Site"). Right-click -> "Properties" -> "ISAPI Filter" -> Add "-> Filter Name: Jakarta, executable: C: / Tomcat 5.0 / conf / jk2 / isapi_redirector2.dll. Click "OK" to save. (JK2 here is the folder used in step 3.)
8. Configure virtual directory for redirection (very critical step)
Right-click "Default Web Site" -> New -> Virtual Directory -> Next -> Alias Fill: Jakarta -> Next -> Directory Selection to: C: / Tomcat 5.0 / Conf / JK2 -> Next -> "Execute (eg, ISAPI application or cgi)" one must be hook-> Next -> Complete. (Be sure to pay attention to the name of Jakarta can't change, because this name corresponds to Jakarta in this registry, if the name spelling error will result in failure.)
Restart the "default Web site". Then right-click "Default Web Site" -> "Properties" -> "Isapi Filter", if the arrow in front of "Jakarta" is green and the priority is "high", then the configuration has been successful.
If the arrow is red, please retrieve the entire configuration process and see if there is a wrong place. If you confirm that everything is correct, please restart your machine, pay attention to restart your machine instead of restart IIS, re-view its status, so that this problem can generally solve this problem. If you can't still do, please contact me.
10. Set environment variable tomcat_home
On the desktop, "My Computer" is right -> "Properties" -> "Advanced" -> Environment Variables -> System Variables -> New Variable Name: Tomcat_Home, Variable Value: C: / Tomcat 5.0 -> Click "OK" to save.
11. Copy Java Compilation Toolkit Tools.jar
Copy the Tools.jar under the C: /J2SDK1.4.1_02/lib directory to the common / lib directory in the Tomcat installation directory (C: / Tomcat 5.0 / COMMON / LIB / D).
12. Add a default document
Start menu -> Settings -> Control Panel -> Administrative Tools -> Internet Service Manager -> Find your site (my computer name is bbbear, "default Web site") -> 点 右 键 -> "Properties" -> "Document" -> Add -> Enter "INDEX.JSP" -> OK -> Add "INDEX.HTML" -> OK (because this is the default start page of Tomcat) ->.
13. Set the website root path
"Home Catalog" -> "Local Path" column, select "C: / Tomcat 5.0 / WebApps / root".
14. Restart Tomcat and IIS
Restart Tomcat and then restart IIS.
15. Look at our results
Open http: // localhost /. What have you seen, pair, Tomcat's default page. Is it familiar with the image of "Cat" to make you feel excited. Well, don't panic, the priest is still behind. In fact, you shouldn't be surprised to see the Tomcat start page, because you look carefully, you will understand, "html" pair, it is just a static page, and is parsed by IIS. Ok, you now try to open http: // localhost / jsp-esamples to see, return "This page cannot be displayed" error page, why? Well, in fact, the reason is very simple, because our IIS's default directory is under / webapps / root, and the JSP-Examples directory is a subdirectory that belongs to the same level as the root. So when you use the above path access, IIS cannot find JSP-Examples in the root directory. How to do? Well, if you are very familiar with IIS, you must think of it, right, the current site in IIS is well established. Ok, we now build a virtual directory named JSP-Examples in IIS, the path is C: / Tomcat 5.0 / webapps / jsp-examples (this directory is the JSP example program comes with Tomcat), and it is created a named servlets. -examples, the path is a virtual directory for C: / Tomcat 5.0 / WebApps / servlets-Examples (this directory corresponds to an example program that comes with the SERVLET with Tomcat). Why do you want to do this? You will know later.
Now you use the http: // localhost / this path to access, then find the link of JSP Examples and Servlet Examples in the bottom left of the Tomcat start page, you can see a JSP Samples after you click on JSP Examples. Page, there are many JSP routines here, you just find one, then click "Execute", see what the result is? If it is normal return result page, Well, congratulations, this means we can start exclaiming, because this represents our previous efforts have been returned, IIS has successfully handed the JSP page to Tomcat.
Ok, now let's take a look at letting the IIS forwarding a servlet request, let's go back to the Tomcat start page, then try to click Servlet Examples link, Well, you will see a servlet Samples page, now you are also looking for A servlet program then click "EXECUTE" to see if you don't accident, you should see the correct return result. Well, I am now solemnly announced that you have successfully completed the perfect combination of Tomcat and IIS. Congratulations! !
16. Need to have a few words
When you are configured when you debug, there is no problem, but it is the page that appears "Unable to display"? why? Here you need to pay attention to three points:
First, Tomcat's startup requires some time, especially if you use Struts on Tomcat, this problem is especially prominent. To see if Tomcat successfully started, you can view the Tomcat log file: c: /tomcat/logs/stdout.log, if you already contain "Server Startup In 1125 MS", you have confirmed that Tomcat service has started successfully.
Second, it is easy to appear some strange phenomena in debugging, for example: change the configuration, but the result page does not change. Well, this problem is the most prone to problem in developing the web program. I also tell you some of the avoidance methods according to the experience of developing a web program. When you change the configuration, you should do not continue on the previous open page. Try, you should reopen a window, because IE is accessing a page cache, he saves some pages that have been opened to improve performance, but this performance may be a nightmare for developers. Third, after changing the file of the WORKERS2.Properties, if you want it to take effect, you must restart IIS, pay attention to it is complete, not stopped in the IIS manager, but let the IIS process restart, of course if you You can also start your computer.
At the end of the article, I would like to express my gratitude to all the friends who have published similar articles, because I also tried successfully on the way they had already gone! Welcome to me questions and valuable comments, let's discuss and solve all the problems we have encountered! If I discovered new problems in the future, I will also add to this article to ensure that this article can really help you. If you like you can reprint this article, please indicate the source, thank you!
my contact information:
Nickname: Stupid bear
QQ: 16401731
Email: Netfaery@163.com
BLOG: http://blog.9cbs.net/netfaery
Because I used the 9CBS blog, after I finished, I was very interested to go to Google, and I found out that there was a similar article in 9cbs already had a friend, and also with an illustration, original I am also ready to match the illustration, but it seems that there is no need now, you can also refer to the article of this friend: http://blog.9cbs.net/arielXp/archive/2004/06/27/27878.aspx.