阅读更多
After reading “Introducing Apache Tomcat 6″ presentation by Mladen Turk I decided to enable Apache Portable Runtime (APR) native library for Tomcat. It was supposed to be as easy as
view sourceprint?
1.sudo ./configure
2.sudo make
3.sudo make install
but as you may guess, it was a little bit more than that.
1. Installing Apache APR.
“Most Linux distributions will ship packages for APR” – those of Linode don’t, I had a barebone Ubuntu 10.10 box without even "gcc" and "make", let alone Apache APR. Thanks God, networking was not an issue, unlike last time.
view sourceprint?1.wget http://apache.spd.co.il//apr/apr-1.4.2.tar.gz
2.tar -xzf apr-1.4.2.tar.gz
3.rm apr-1.4.2.tar.gz
4.cd apr-1.4.2/
5.sudo apt-get install make
6.sudo ./configure
7.sudo make
8.sudo make install
2. Installing Tomcat Native.
view sourceprint?
1.wget http://off.co.il/apache//tomcat/tomcat-connectors/native/1.1.20/source/tomcat-native-1.1.20-src.tar.gz
2.tar -xzf tomcat-native-1.1.20-src.tar.gz
3.rm tomcat-native-1.1.20-src.tar.gz
4.cd tomcat-native-1.1.20-src/jni/native
5.sudo ./configure --with-apr=/usr/local/apr
The result was
view sourceprint?
1.checking build system type... x86_64-unknown-linux-gnu
2...
3.checking for APR... yes
4...
5.checking for JDK location (please wait)... checking Try to guess JDK location...
6.configure: error: can't locate a valid JDK location
Ouch! "Can't locate a valid JDK location"? On my machine?
view sourceprint?
1.$ which java
2./home/user/java/jdk/bin/java
3.$ echo $JAVA_HOME
4./home/user/java/jdk
5.$ java -version
6.java version "1.6.0_24"
7.Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
8.Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)
But for some reason "tomcat-native-1.1.20-src/jni/native/configure" script didn’t see my "JAVA_HOME" variable no matter what and even installing "sun-java6-jdk" didn’t help much. After patching the "configure" script to dump locations it was looking for “valid JDK” I had:
view sourceprint?
01...
02.configure: [/usr/local/1.6.1]
03.configure: [/usr/local/IBMJava2-1.6.0]
04.configure: [/usr/local/java1.6.0]
05.configure: [/usr/local/java-1.6.0]
06.configure: [/usr/local/jdk1.6.0]
07.configure: [/usr/local/jdk-1.6.0]
08.configure: [/usr/local/1.6.0]
09.configure: [/usr/local/IBMJava2-1.6]
10.configure: [/usr/local/java1.6]
11.configure: [/usr/local/java-1.6]
12.configure: [/usr/local/jdk1.6]
13.configure: [/usr/local/jdk-1.6]
14...
Ok then, here you have it now:
view sourceprint?
1.sudo ln -s ~/java/jdk/ /usr/local/jdk-1.6
2.sudo ./configure --with-apr=/usr/local/apr
3.sudo make
4.sudo make install
And with
view sourceprint?
1...
2.export LD_LIBRARY_PATH='$LD_LIBRARY_PATH:/usr/local/apr/lib'
3...
I now had a beautiful log message in "catalina.out":
view sourceprint?
1...
2.Mar 7, 2011 11:51:02 PM org.apache.catalina.core.AprLifecycleListener init
3.INFO: Loaded APR based Apache Tomcat Native library 1.1.20.
4.Mar 7, 2011 11:51:02 PM org.apache.catalina.core.AprLifecycleListener init
5.INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
6.Mar 7, 2011 11:51:03 PM org.apache.coyote.AbstractProtocolHandler init
7...
s soon as "evgeny-goldin.org" moves to its new location on the brand-new Linode box it will benefit from this performance optimization. I’ll describe the migration process and reasons for it a bit later, once it is done.
From http://evgeny-goldin.com/blog/ubuntu-installing-apr-tomcat/
原文地址:http://java.dzone.com/articles/ubuntu-installing-apache