当前位置:首页 >> 服务器

Linux下Tomcat8.0.44配置使用Apr的方法

听说Apr可以提高tomcat很多的性能,配置具体如下

1.安装apr 1.5.2

[root@ecs-3c46 ]# cd /usr/local/src
[root@ecs-3c46 src]# wget http://apache.fayea.com//apr/apr-1.5.2.tar.gz
[root@ecs-3c46 src]# tar -xzvf apr-1.5.2.tar.gz
[root@ecs-3c46 src]# cd apr-1.5.2
[root@ecs-3c46 apr-1.5.2]# ./configure --prefix=/usr/local/apr
[root@ecs-3c46 apr-1.5.2]# make
[root@ecs-3c46 apr-1.5.2]# make install

2.安装apr-util-1.5.4

[root@ecs-3c46 ]# cd /usr/local/src
[root@ecs-3c46 src]# wget http://mirrors.hust.edu.cn/apache//apr/apr-util-1.5.4.tar.gz
[root@ecs-3c46 src]# tar -xzvf apr-util-1.5.4.tar.gz
[root@ecs-3c46 src]# cd apr-util-1.5.4
[root@ecs-3c46 apr-util-1.5.4]# ./configure --prefix=/usr/local/apr
[root@ecs-3c46 apr-util-1.5.4]# make
[root@ecs-3c46 apr-util-1.5.4]# make install

3.如果没有安装openssl的请安装下openssl,已经安装的继续下一步

4.安装 tomcat-native组件,发现在tomcat8.0.44的bin目录下面已经有相关文件tomcat-native.tar.gz

解压后得到tomcat-native-1.2.12-src文件夹

[root@ecs-3c46 bin]# tar -xzvf tomcat-native.tar.gz
[root@ecs-3c46 bin]# cd tomcat-native-1.2.12-src/native
[root@ecs-3c46 native]# ./configure --with-apr=/usr/local/apr --with-java-home=/usr/local/java/jdk1.7.0_80 --with-ssl=/usr/local/openssl --prefix=/usr/local/tomcat/apache-tomcat-8.0.44
[root@ecs-3c46 native]# make
[root@ecs-3c46 native]# make install

5.tomcat配置,默认tomcat8.0.44是启用Apr的,在Listener结点配置

<Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener"/>

重启tomcat服务后出现一个问题,表示还没有成功使用Apr

27-Jul-2017 15:50:13.488 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib

解决方法:

在/usr/java/packages/lib/amd64目录下面创建/usr/local/apr/lib/libtcnative-1.so.0.2.12的链接

[root@ecs-3c46 native]# cd /usr/java/
[root@ecs-3c46 java]# mkdir packages/
[root@ecs-3c46 java]# cd packages/
[root@ecs-3c46 packages]# mkdir lib
[root@ecs-3c46 packages]# cd lib
[root@ecs-3c46 lib]# mkdir amd64
[root@ecs-3c46 lib]# cd amd64
[root@ecs-3c46 amd64]# ln -s /usr/local/apr/lib/libtcnative-1.so.0.2.12 libtcnative-1.so
[root@ecs-3c46 amd64]# ln -s /usr/local/apr/lib/libtcnative--1.so.0.2.12 libtcnative-1.so.0

6.重新启动tomcat,如果显示如下信息就表示已经配置成功了。

27-Jul-2017 16:16:29.479 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library 1.2.12 using APR version 1.5.2.
27-Jul-2017 16:16:29.479 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
27-Jul-2017 16:16:29.491 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized (OpenSSL 1.0.2l 25 May 2017)

以上这篇Linux下Tomcat8.0.44配置使用Apr的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。