How to compile Apache 2 module mod_jk2 for Tomcat 5 on
Windows ? |
Abstract: |
This text covers the compilation of the Apache 2
module mod_jk2 for Tomcat 5 on Windows. The result is a mod_jk2.dll
to be used to enable Apache 2 to integrate with Tomcat 5 on Windows
systems.
These instructions have been tested on Windows 2000 with Apache
2.0.48, Tomcat 5.0.18, ANT 1.5.3, Java 2 1.4 and Microsoft Visual
Studio 6. |
|
Prerequisites: |
Properly installed J2SE SDK with JAVA_HOME set in
your environment.
Properly installed Microsoft Visual Studio. |
|
Install Apache 2: |
1. |
Download the Windows binaries:
apache_2.0.48-win32-x86-no_ssl.exe |
2. |
Install Apache 2 by double-clicking on the downloaded file and
following the prompts. |
2a. |
As Setup Type choose Custom Installation:
This feature installs the headers and libraries required to compile
and link additional modules. Additionally you can specify the
location where Apache 2 is to be installed. |
2b. |
Follow the next prompts. |
3. |
Set APACHE2_HOME in your environment to point to the
Apache 2 installation directory. |
|
Install ANT: |
1. |
Download the ANT distribution:
apache-ant-1.5.3-1-bin.zip |
2. |
Unpack the distribution in the desired directory. |
3. |
Set ANT_HOME in your environment to point to the ANT
installation directory. |
|
Install Tomcat source code: |
1. |
Download the Tomcat source code:
jakarta-tomcat-5.0.18-src.tar.gz |
2. |
Unpack the source code in the desired directory. |
|
The Tomcat Connectors are supplied with the source
code. |
|
Compiling Step 1: jkant.jar: |
1. |
Go to the jk directory in your
Tomcat source code directory:
cd jakarta-tomcat-connectors/jk |
2. |
Compile and build jkant.jar:
ant jkant |
|
Now the jkant.jar is built and can be found
in:
jakarta-tomcat-connectors\jk\build\lib\jkant.jar
The next compiling step needs this file, you do not
have to handle this file! |
|
Compiling Step 2: mod_jk.dll: |
1. |
Create a text file named build.properties in
the jakarta-tomcat-connectors\jk directory.
Add the following lines:
# Compile time options for the native code
so.debug=false
so.optimize=true
|
2. |
Go to the native2 directory:
cd jakarta-tomcat-connectors\jk\native2 |
3. |
Compile and build mod_jk2.dll:
ant |
|
Troubleshooting:
Error:
BUILD FAILED
[...] CreateProcess: "C:\Program Files\Microsoft Visual
Studio\VC98\bin\mc" jk_logger_win32_message.mc error=3
Solution:
The
jakarta-tomcat-connectors\jk\native2\build.xml is
designed to work with Microsoft Visual Studio. The path to the MS
Visual Studio installation directory is hard coded as the author of
the build.xml expects it to be in C:\Program
Files\Microsoft Visual Studio\VC98. My installation directory
is different, so I had to adjust the path with the
build.properties file.
# MSVC
mssdk.home=D:/programme/MicrosoftVisualStudio/VC98
Add the two lines above to the build.properties file. This
is the only content needed to adjust the above problem. Use slashes
/ in the path, no backslashes \. You already created the
build.properties file in the
jakarta-tomcat-connectors\jk directory.
Use your own path, the above is only a sample, actually it is my
path! ;-)
Error:
BUILD FAILED
[...] Cannot open include file: 'apr.h': No such
file or directory
Solution:
Set APACHE2_HOME to point to the Apache2 installation
directory. |
4. |
Now the mod_jk2.dll is built and can be
found in:
jakarta-tomcat-connectors\jk\build\jk2\apache2\mod_jk2.dll
This file is specific to the Apache 2.0.48, so it is
a good idea to rename it to:
mod_jk2_2.0.48.dll |
|
Install mod_jk2.dll: |
1. |
Copy the file mod_jk2_2.0.48.dll into your
Apache 2 installation directory \modules. |
2. |
Now you can configure Apache 2 to integrate Tomcat
4 using the mod_jk2_2.0.48.dll. |
3. |
Download: mod_jk2.dll |
|
Comment: Compiling Tomcat 5.0.18
connectors |
|
The two files jk_channel_socket.c and
jk_pool.c will not compile. They show a deprecated error
message. The developer left this error unintentional in the source
code commiting the file to CVS. You can safely uncomment the #error
line in this two files.
|
|
Comment: Microsoft Visual Studio |
|
Why is Microsoft Visual Studio needed?
To compile mod_jk2.dll the jkant.jar is needed. This
jar extends ANT and provides special compiler tasks:
org.apache.jk.ant.compilers.MsvcCompiler
org.apache.jk.ant.compilers.MsvcLinker
These tasks are programmed to work with MS Visual Studio only.
Microsoft Visual Studio provides header files needed to compile
mod_jk2.dll on Windows correctly. Other compilers do not
provide these header files, e.g. the free Borland C++ 5.5
compiler.
|
|