参考文献
http://jmchung.github.io/blog/2013/09/06/centos-installing-apache-portable-runtime-apr-for-tomcat/
# cd $CATALINA_HOME/bin
# tar -zxvf tomcat-native.tar.gz
# cd tomcat-native-1.1.27-src/jni/native
# ./configure --with-apr=/usr/local/apr --with-java-home=/usr/local/jdk1.8.0_91
# make
# make install
The native libraries were installed in /usr/local/apr/lib
Integrate APR with Tomcat
There are two ways to set Tomcat integrate with APR. One is you can add the following parameter when start up the Tomcat in bin/catalina.sh
:
CATALINA_OPTS="-Djava.library.path=/usr/local/apr/lib"
The other is to add a new environment variable LD_LIBRARY_PATH
in /etc/profile
:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apr/lib
Then makes it effect via:
# source /etc/profile
After restarting the Tomcat service, we can get the following message in catalina.out
log if APR was installed successfully.
Sep 06, 2013 2:10:09 AM org.apache.catalina.core.AprLifecycleListener init INFO: Loaded APR based Apache Tomcat Native library 1.1.27 using APR version 1.4.8. Sep 06, 2013 2:10:09 AM org.apache.catalina.core.AprLifecycleListener init INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
Tomcat SSLEngine Error
SEVERE: Failed to initialize the SSLEngine. org.apache.tomcat.jni.Error: 70023: This function has not been implemented on this platform at org.apache.tomcat.jni.SSL.initialize(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.catalina.core.AprLifecycleListener.initializeSSL(AprLifecycleListener.java:259) at org.apache.catalina.core.AprLifecycleListener.lifecycleEvent(AprLifecycleListener.java:110) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90) at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:402) at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:99) at org.apache.catalina.startup.Catalina.load(Catalina.java:640) at org.apache.catalina.startup.Catalina.load(Catalina.java:665) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:281) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:455)
If you got the SSLEngine error message and your site without SSL support, you can fix this error via turn this initialization off in conf/server.xml
.
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="off" />