读好书,交益友
分类: Java
2014-03-20 16:46:16
最近使用tomcat,为了提升性能要使用Native Library。这个在windows上是默认使用的,在linux还得重新编译。
centos 默认安装
yum install apr
好像不行。必须源码安装
wget
tar -zxvf apr-1.5.0.tar.gz
cd apr-1.5.0
./configure
make
make install
默认安装在 /usr/local/apr
进入tomcat的bin目录
tar -zxvf tomcat-native.tar.gz
cd tomcat-native-1.1.20-src/
cd jni/native
./configure --with-apr=/usr/local/apr --with-java-home="/usr/lib/jvm/java-1.7.0" --with-ssl=yes
make
make install
默认安装在
/usr/local/apr/lib
cd /usr/lib
ln -s /usr/local/apr/lib/libapr-1.so.0.5.0 lib-apr-1.so
ln -s /usr/local/apr/lib/libapr-1.so.0.5.0 lib-apr-1.so.0
ln -s /usr/local/apr/lib/libtcnative-1.so.0.1.20 libtcnative-1.so
ln -s /usr/local/apr/lib/libtcnative-1.so.0.1.20 libtcnative-1.so
或者tomcat安装目录bin下创建setenv.sh文件:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CATALINA_HOME/lib
export LD_LIBRARY_PATH
检查
conf/server.xml中
<Connector port="8080" protocol="org.apache.coyote.http11.Http11AprProtocol" maxThreads="150" connectionTimeout="20000" redirectPort="8443" >
如果配置成功,启动 tomcat,会看到如下信息:
org.apache.coyote.http11.Http11AprProtocol init