Thursday, October 16, 2008

Installing Apache portable runtime (APR) for tomcat 6.0.x

Tomcat can now use Apache Portable Runtime and using APR results in performance boost.
Below we detail the steps to get tomcat native library installed on a linux system
(I am using Red hat but steps should be similar for other distros)

Download and install APR



wget http://apache.norhex.com/apr/apr-1.3.3.tar.gz
mkdir x
mv apr-1.3.3.tar.gz x/
408 tar -zxvf apr-1.3.3.tar.gz
409 cd apr-1.3.3
416 gcc -v
417 ./configure --prefix=/opt/apr
418 make
419 make install



Download and compile openssl tarball corresponding to your system
(Latest version maybe incompatible with your system)




424 openssl version -a
426 wget http://www.openssl.org/source/openssl-0.9.8b.tar.gz
427 tar -zxvf openssl-0.9.8b.tar.gz
429 cd openssl-0.9.8b
431 ./Configure
433 ./config --prefix=/opt/apr --openssldir=/opt/openssl shared
434 make
435 make test
436 make install


Download and install sun JDK .

You have to put /usr/java/latest/bin in your path to pick SUN JDK ahead of GCJ.




466 uname -a
467 java -version
468 links http://java.sun.com/javase/downloads/index.jsp
chmod +x jdk-6u10-linux-i586-rpm.bin
411 ./jdk-6u10-linux-i586-rpm.bin
418 /usr/java/latest/bin/java -version
419 echo $PATH
423 vi .bash_profile
424 . .bash_profile
425 echo $PATH
426 java -version




Download and install tomcat native source



443 wget http://tomcat.heanet.ie/native/1.1.10/source/tomcat-native-1.1.10-src.tar.gz
444 tar -zxvf tomcat-native-1.1.9-src.tar.gz
445 cd tomcat-native-1.1.10-src/jni/native
464 ./configure --help
440 ./configure --prefix=/opt/apr/ --with-ssl=/opt/apr --with-apr=/opt/apr
--with-java-home=/usr/java/latest --with-java-platform=2

460 make
467 make install
468 ls /opt/apr/lib/
469 ldd /opt/apr/lib/libtcnative-1.so.0


if configure complains about not finding openSSL then set LD_LIBRARY_PATH to include /opt/apr/lib.




454 echo $LD_LIBRARY_PATH
455 LD_LIBRARY_PATH=/opt/apr/lib
456 export LD_LIBRARY_PATH




Put tomcat native library in LD_LIBRARY_PATH before starting tomcat. Start tomcat and check catalina log file to verify that tomcat is using APR.



# setup native library in path
LD_LIBRARY_PATH=/opt/apr/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
/usr/local/apache-tomcat-6.0.16/bin/startup.sh


© Life of a third world developer
Maira Gall