Tomcat Native 这个项目可以让 Tomcat 使用 Apache 的 apr 包来处理包括文件和网络IO操作,以提升性能。其项目下载主页为:http://tomcat.apache.org/download-native.cgi 。默认在下载的tomcat里的bin目录带的有该项目的tar包 。
一、安装
tomcat native的安装需要依赖openssl 、apr、apr-util ,openssl可以通过 yum 方式安装 。 apr、apr-util也可以通过yum安装,不过版本太老,可以通过源码包安装。
apr的安装
tar zxvf apr-1.4.8.tar.gz cd apr-1.4.8 ./configure make && make install
ap-util的安装
tar zxvf apr-util-1.5.2.tar.gz cd apr-util-1.5.2 ./configure --with-apr=/usr/local/apr make && make install
tomcat native的安装
cd apache-tomcat-7.0.42/bin/tomcat-native-1.1.27-src/jni/native/ ./configure --with-apr=/usr/local/apr make && make install
tomcat native还需要依赖java环境,由于我已经在/etc/profile里配置过了java 。所以该处并未指定 。
二、配置环境变量并使用
在/etc/profile里增加以下行:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apr/lib
配置完成后,并source /etc/profile生效 。配置完成后,启动tomcat并查看catalina.out输出,如果出现如下信息表示安装成功:
INFO: Loaded APR based Apache Tomcat Native library 1.1.27 using APR version 1.4.8.