Apache-Tomcat-jk_mod.rtf

http://www.jajakarta.org/tomcat/tomcat3.2-4.0/tomcat-3.2.3/doc/tomcat-apache-howto.html


http://www.mulesoft.com/apache-tomcat-mod-jk-connector-configuration


http://www.johnturner.com/howto/apache2-tomcat4129-jk-winxp-howto.html

http://onsmalltalk.com/running-seaside-apache-and-iis-on-windowsxp


Apache doc: http://www.jajakarta.org/tomcat/tomcat3.2-4.0/tomcat-3.2.3/doc/mod_jk-howto.html

This is Good:Apache-Tomcat-jk_mod.rtf (23.08 mb)

More details below: last update: 12/13/2003

Building an Apache HTTP + Tomcat environment is five major steps:

  1. install JDK
  2. install Apache
  3. install Tomcat
  4. install a connector, in this case JK
  5. configure and test

Since Tomcat is 100% Java, we'll use the binary install instead of having to deal with ant. My preference is to put things in locations on disk so that spaces are not part of the path name. Use whichever location suits your purposes, but there have been many posts on various mailing lists where path names with spaces caused mysterious, hard to diagnose problems. It's best to avoid them when possible. Aside from that, paths in this scenario don't have much effect as long as you can guarantee that they are consistent throughout the various configuration steps.

Assumptions

  1. Directory names, folder names, and any path names WILL NOT have spaces in them. Whenever possible, store things in places where the path names do not have spaces.
  2. Mod_jk is used as the Apache connector.
  3. You don't want multiple virtual hosts. If you want to have multiple virtual hosts, that is, more/other than http://localhost, check out my Virtual Hosting HOWTO. (coming soon)
  4. You want Tomcat and Apache installed as services, not as user-level applications.
  5. Your user account has administrator privileges. If it doesn't, find someone who does.

Install JDK

  1. go to Sun's Java download site and download J2SE for Windows: http://java.sun.com/j2se/1.4.2/download.html. I prefer the SDK version, and I prefer the Offline Installation version. Offline because then you can copy it to a shared folder or even burn it to a CD, and install it as many times as you like without needing an Interne connection. From here on out, I will assume that you've got the SDK version, and are using the Offline Installation version. When you finish downloading, you will have a file called j2sdk-1_4_2_01-windows-i586.exe.
  2. To install J2SDK, just execute the file you downloaded. Once the Installer is finished unpacking, you'll be presented with a standard license prompt. (screenshot) If you agree, choose the appropriate option and click Next.
  3. The installer will display a standard installation dialog. (screenshot) Click Next. This will install J2SE in C:\j2sdk1.4.2_01, which is fine.
  4. Register the browsers on your system, and click Install. (screenshot)
  5. After the install has finished, click Finish.

Build/Install Apache HTTP

  1. First and foremost, make sure you do not have a web server or other process already listening on port 80. Click Start->Administrative Tools->Services and scroll the right hand window pane until you can see the service named World Wide Web Publishing. Highlight that service, and click the Stop icon in the toolbar. (screenshot)
  2. While you have the Services applet open, choose the World Wide Web Publishing service again, and click on the Properties icon in the toolbar. In the next window, choose Manual where it says Startup type. Click OK, then close the Services applet. (screenshot)
  3. Download the Windows MSI Apache distribution from a mirror. You want version 2.0.48. The filename is apache_2.0.48-win32-x86-no_ssl.msi.
  4. Execute the MSI installer. You'll see a welcome screen. (screenshot)
  5. Click Next. Accept the terms of the license, and click Next again. The README file will be displayed. Read through it, and when finished, click Next.
  6. On the next screen, replace the default values with localhost for Network Domain and Server Name. For Email Address, use your email address or any other value you wish. Make sure to choose the option For All Users, on Port 80 as well. Click Next when ready. (screenshot)
  7. On the next screen, choose Typical and click Next.
  8. We are going to put Apache 2.0.48 in a directory called C:\ApacheGroup. Notice the lack of spaces in the path name. To do this, click the button that says Change and use the file dialog box to change to the C:\ drive, where you will create a new folder called ApacheGroup. When finished, your screen should look like this. If it does, click Next to continue to the next screen.
  9. You should be looking at the final screen before the install process begins. (screenshot) Click Install to begin the installation.
  10. When the installation is finished, a screen will be displayed. Click the Finish button. You should now have an Apache instance in C:\ApacheGroup\Apache2. Verify the installation by opening a web browser and browsing to http://localhost. If everything installed correctly, you will see an Apache Welcome page.
  11. Shutdown Apache until you can get the connector installed by right-clicking on the Apache monitor service in your taskbar (it's the tiny feather icon), and selecting Stop. (screenshot)

Build/Install Tomcat

  1. First, create a folder on your hard drive. Call it Tomcat, and put it in the C drive root, so that you end up with C:\Tomcat. NOTE: You can put Tomcat wherever you like, it is your choice. Wherever you put it, try to keep spaces or other unusual characters out of the pathname.
  2. Now, grab the Windows EXE distribution for Tomcat 4.1.29 from a mirror site. The filename is jakarta-tomcat-4.1.29.exe
  3. Once it is downloaded, execute the file.
  4. Agree to the license, and click Next. On the next screen, check the box marked NT Service. (screenshot) Click Next again.
  5. Next, change the directory where Tomcat will be installed. Change the default so that there are no spaces in the pathname. (screenshot)
  6. When the install completes, you'll be presented with a final screen that will let you test your installation. (screenshot) Make sure to use a decent password for the admin user. Click Next to verify and complete the installation.
  7. At this point, Tomcat should be running. Browse to http://localhost:8080 to be sure. If everything is ready, you'll see the Tomcat Welcome page. Verify the Tomcat examples are available at http://localhost:8080/examples.

Install the Connector

The two connectors (JK and JK2) are different; JK2 is a complete rewrite of the earlier JK/AJP13 protocol. We'll cover installing JK here. For JK2, check out my JK2 HOWTO (coming soon).

  1. Download the connector binary for Windows from a Jakarta mirror site. Scroll down to where it says Tomcat Web Server Connectors and then click on JK 1.2 Binary Releases. Click on the Win32 folder and download the file named mod_jk_1.2.5_2.0.47.dll.
  2. When the download is complete, copy the DLL file to C:\ApacheGroup\Apache2\modules. Rename the file to mod_jk.dll. This will leave you with C:\ApacheGroup\Apache2\modules\mod_jk.dll. The location on your system may be different…that's fine, the point is to put the JK DLL file in Apache's modules directory, wherever that may be.

Final Configuration

NOTE: these steps will allow access to the Tomcat examples via Apache on port 80. Successful use of the examples on port 80 shows that mod_jk is working correctly, since Tomcat is configured to run on port 8080 by default for HTTP requests.

  1. You're going to be making edits to a file called server.xml in Tomcat's conf directory. If you've used the installation locations suggested previously, the file you want is C:\Tomcat\Tomcat-4.1\conf\server.xml. This file is vital to Tomcat operation, so it is a good idea to make a copy before it gets modified.
  2. Now, let's edit server.xml in Tomcat's conf. Use any editor you'd like. For our purposes, we'll use Notepad.
  3. Look for a line that says "Server" and has a port of 8005. Add the following directly below:
    <Listener className="org.apache.ajp.tomcat4.config.ApacheConfig" modJk="C:/ApacheGroup/Apache2/modules/mod_jk.dll" />
  4. In the Host container add the following Listener directive (yes, it looks very similar to the one above):
    <Listener className="org.apache.ajp.tomcat4.config.ApacheConfig" append="true" forwardAll="false" modJk="C:/ApacheGroup/Apache2/modules/mod_jk.dll" />
    Save your changes and exit the editor.
  5. Now, we need to make a small edit to Apache's httpd.conf. Edit httpd.conf in APACHE_HOME/conf. Don't worry about making a copy, the Apache team put one there for you already (it's called httpd-std.conf). Like editing server.xml, use any editor you'd like.
  6. Add a single line at the end of the file:
    Include "C:/Tomcat/Tomcat-4.1/conf/auto/mod_jk.conf"
    Note: the mod_jk.conf file gets created by Tomcat when Tomcat starts. It gets created every time Tomcat starts. So, if you have your server.xml configured, you can ignore httpd.conf (in most cases) except to add the Include directive for mod_jk.conf. You don't need to create or edit mod_jk.conf, Tomcat will do this for you. Click here for a sample mod_jk.conf file generated automatically by Tomcat on each startup.
  7. Create a file in C:\Tomcat\Tomcat-4.1\conf\jk called workers.properties. In that file, put the following lines:
    worker.list=ajp13
    worker.ajp13.port=8009
    worker.ajp13.host=localhost
    worker.ajp13.type=ajp13
    Save the file. This file provides necessary information to mod_jk, like where to find Tomcat and what port to use when connecting.
  8. Start Tomcat: Wait at least 30 seconds for tomcat to complete the startup process. Verify that you have a file called C:\Tomcat\Tomcat-4.1\conf\auto\mod_jk.conf and that the timestamp on that file is recent before going to the next step. An example mod_jk.conf file can be found here.
  9. Start Apache.
  10. Verify examples at http://localhost:8080/examples. On success, Tomcat is working correctly.
  11. Verify examples at http://localhost/examples. On success, Apache is working correctly, and JSP and servlet requests are being passed to Tomcat.