安装apr 1.5.2
# wget http://apache.fayea.com//apr/apr-1.5.2.tar.gz
# tar -xzvf apr-1.5.2.tar.gz
# cd apr-1.5.2
# ./configure --prefix=/usr/local/apr
# make
# make install
安装 tomcat-native组件
下载 http://mirrors.hust.edu.cn/apache//apr/apr-util-1.5.4.tar.gz
tar -xzvf tomcat-native.tar.gz
cd tomcat-native-1.2.7-src/native
./configure --with-apr=/usr/local/apr
//出现如下错误
//Found OPENSSL_VERSION_NUMBER 0x1000105f (OpenSSL 1.0.1e 11 Feb 2013)
//Require OPENSSL_VERSION_NUMBER 0x1000200f or greater (1.0.2)
//configure: error: Your version of OpenSSL is not compatible with this version of tcnative</span>
安装OpenSSL 1.0.2
由于centos 6.5 当前的yum 库只有1.0.1 的OpenSSL,所以我们需要手工安装1.0.2
# cd /usr/local/src
# wget https://www.openssl.org/source/openssl-1.0.2-latest.tar.gz
# tar -xzxf openssl-1.0.2-latest.tar.gz
# cd openssl-1.0.2g
# ./config --prefix=/usr/local/openssl -fPIC
// 注意这里需要加入 -fPIC参数,否则后面在安装tomcat native 组件会出错
// 注意:不要按照提示去运行 make depend
# make
# make install
# mv /usr/bin/openssl ~
# ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
# openssl version
// 确认版本信息是1.0.2
重新安装 tomcat-native组件
# cd $CATALINA_HOME/bin
# tar -xzvf tomcat-native.tar.gz
# cd tomcat-native-1.2.7-src/native
# ./configure --with-apr=/usr/local/apr --with-ssl=/usr/local/openssl
# make
# make install<pre name="code" class="html">export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apr/lib
export LD_RUN_PATH=$LD_RUN_PATH:/usr/local/apr/lib
设置 Tomcat 整合 APR
有三种方法
(1)
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apr/lib
export LD_RUN_PATH=$LD_RUN_PATH:/usr/local/apr/lib
(2)修改 tomcat 的启动 shell ( catalina.sh ),在该文件中加入启动参数: CATALINA_OPTS="$CATALINA_OPTS -Djava.library.path=/usr/local/apr/lib" 。
(3)也可以在环境变量中配置/etc/profile中加入 export CATALINA_OPTS="$CATALINA_OPTS -Djava.library.path=/usr/local/apr/lib"
source /etc/profile
tomcat配置APR模式
org.apache.coyote.http11.Http11NioProtocol,启动生效。
<Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol"
connectionTimeout="20000"
redirectPort="8543" />
日志查看APR