Tomcat Native Module

26 Dec 2012

To install libtcnative you must first have a working C compiler environment, a valid apr and openssl installation with their related development libraries, a working Tomcat installation and a Java JDK.

Bash
1
2
3
4
$ echo $CATALINA_HOME
/opt/xyz/tomcat
$ echo $JAVA_HOME
/opt/xyz/java

In the Tomcat native directory:

Bash
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
$ which apr-1-config
/usr/bin/apr-1-config

cd $CATALINA_HOME/bin

tar zxvf tomcat-native.tar.gz

cd tomcat-native-1.1.24-src/jni/native

./configure \
  --with-apr=`which apr-1-config` \
  --with-java-home=$JAVA_HOME \
  --with-ssl=yes \
  --prefix=$CATALINA_HOME

make

make install

Now check that the native SO is installed in $CATALINA_HOME/lib:

1
2
3
4
5
-rw-r--r-- 1 xyz xyz  1594610 Dec  2  2012 libtcnative-1.a
-rwxr-xr-x 1 xyz xyz      894 Dec  2  2012 libtcnative-1.la
lrwxrwxrwx 1 xyz xyz       23 Dec  2  2012 libtcnative-1.so -> libtcnative-1.so.0.1.24
lrwxrwxrwx 1 xyz xyz       23 Dec  2  2012 libtcnative-1.so.0 -> libtcnative-1.so.0.1.24
-rwxr-xr-x 1 xyz xyz   894283 Dec  2  2012 libtcnative-1.so.0.1.24

Finally, configure Tomcat’s server.xml:

XML
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
<!--APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />

<Connector port="80" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="443" />
<Connector port="443" protocol="HTTP/1.1" SSLEnabled="true"
           maxThreads="150" scheme="https" secure="true"
           clientAuth="false" sslProtocol="TLS"
           proxyName="myserver.myorg.com"
           address="10.20.30.40"
           SSLCertificateFile="/home/foo/.ssl/server.crt"
           SSLCertificateKeyFile="/home/foo/.ssl/server.key"
           SSLPassword="appfoo3" />