Build tc-native requires three components to be installed:
- APR librrary
- OpenSSL libraries
- Java SE Development Kit (JDK)
Step 1: Install apr Dev Env:
Run command "yum list apr-devel", if not including apr-devel.i386/apr-devel.x86_64m, then install it. In rpm based Linux those dependencies could be installed by something like:
yum install apr-devel openssl-devel
By this time, you should be able to see: /usr/bin/apr-1-config, which will be used for following steps.
yum install wget
Step 3: Download tomcat-native package
wget http://mirror.bjtu.edu.cn/apache//tomcat/tomcat-connectors/native/1.1.22/source/tomcat-native-1.1.22-src.tar.gz
Step 4: Uncompress this file
tar -zxvf tomcat-native-1.1.22-src.tar.gz
Step 5: Drill down to the compile path
cd tomcat-native-1.1.22-src/jni/native
Step 6: Build tc-native.
Read the description of all the parameters:
./configure --help
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-apr=$HOME/APR prefix for installed APR or the full path to apr-config
--with-java-home=$JAVA_HOME Location of JDK directory.
--with-java-platform=2 Force the Java platform (value is 1 for 1.1.x or 2 for 1.2.x or greater)
--with-os-type=SUBDIR Location of JDK os-type subdirectory.
--with-ssl=HOME/OPENSSL Build with OpenSSL yes|no|path
Installation directories:
--prefix=$CATALINA_HOME install architecture-independent files in PREFIX [/usr/local]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX]
to create the includes and makefiles to be able to build tc-native.
Where:
$HOME/APR is something like /usr/bin/apr-1-config or the path where apr is installed.
$JAVA_HOME is something /home/jfclere/JAVA/jdk1.5.0_09 path to a JDK installation. Any JDK should work but it is advisable to use the same JVM version the JVM you use with Tomcat.
$HOME/OPENSSL is the path where OpenSSL is installed.
$CATALINA_HOME is the path where the produced libraries will be installed. Something like $HOME/apache-tomcat-6.0.16/
./configure --with-apr=/usr/bin/apr-1-config --with-java-home=/data/jre --with-ssl=yes --prefix=/data/apr
make && make install
Libraires will be installed in /data/apr/lib.
Step 7:
Add path to the tc-native to LD_LIBRARY_PATH and export it in you starting script.
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/data/apr/lib
export LD_LIBRARY_PATH
Step 8:
Copy tomcat-apr-5.5.23.jar to the class path of you application.
Step 9: update your source code:
IoAcceptor acceptor = new AprSocketAcceptor;