Centos下Tomcat 安装Apache Portable Runtime

APR(Apache Portable Runtime)是一个高可移植库,它是Apache HTTP Server 2.x的核心。

APR有很多用途,包括访问高级IO功能(例如sendfile,epoll和OpenSSL),OS级别功能(随机数生成,系统状态等等),本地进程管理(共享内存,NT管道和UNIX sockets)。这些功能可以使Tomcat作为一个通常的前台WEB服务器,能更好地和其它本地web技术集成,总体上让Java更有效率作为一个高性能web服务器平台而不是简单作为后台容器。在Tomcat中使用JNI的方式来读取文件以及进行网络传输。这个东西可以大大提升Tomcat对静态文件的处理性能,同时如果你使用了HTTPS方式 传输的话,也可以提升SSL的处理性能。

安装过程

1. 下载所需的安装包

到http://apr.apache.org/下载
apr-1.5.2.tar.gz
apr-iconv-1.2.1.tar.gz
apr-util-1.5.4.tar.gz

到http://archive.apache.org/dist/tomcat/tomcat-connectors/native/下载
tomcat-native-1.1.33-src.tar.gz

2. 安装依次安装 apr, apr-iconv, apr-util, tomcat-native
tomcat-native的安装参数可以参考 http://tomcat.apache.org/native-doc/

复制代码
tar zxvf apr-1.5.2.tar.gz 
cd apr-1.5.2
./configure --prefix=/usr/local/share/apr
sudo make
sudo make install

tar zxvf apr-iconv-1.2.1.tar.gz 
cd apr-iconv-1.2.1
./configure --prefix=/usr/local/share/apr-iconv --with-apr=/usr/local/share/apr
sudo make
sudo make install

tar zxvf apr-util-1.5.4.tar.gz 
cd apr-util-1.5.4
./configure --prefix=/usr/local/share/apr-util --with-apr=/usr/local/share/apr --with-apr-iconv=/usr/local/share/apr-iconv/bin/apriconv 
sudo make
sudo make install

tar zxvf tomcat-native-1.1.33-src.tar.gz 
cd tomcat-native-1.1.33-src/jni/native/
./configure --with-apr=/usr/local/share/apr --with-java-home=/usr/java/jdk1.6.0_45 --prefix=/opt/tomcat
sudo make
sudo make install
复制代码

 注意, 最后一步指定了tomcat-native的安装路径是tomcat的安装目录, 而且安装结果会提示你

复制代码
Libraries have been installed in:
   /opt/tomcat/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'
复制代码

所以你要把这个放到系统路径里

sudo vi /etc/profile

Add to last line

export LD_LIBRARY_PATH=/opt/tomcat/lib

保存之后, 在启动tomcat的用户环境下 source /etc/profile, 然后重启tomcat. 安装成功时, tomcat的启动日志会显示类似这样的信息

May 16, 2015 11:32:12 PM org.apache.catalina.core.AprLifecycleListener init
INFO: Loaded APR based Apache Tomcat Native library 1.1.33 using APR version 1.5.2.
May 16, 2015 11:32:12 PM org.apache.catalina.core.AprLifecycleListener init
INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
May 16, 2015 11:32:13 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-apr-8080"]

 

posted on   Milton  阅读(634)  评论(0编辑  收藏  举报

编辑推荐:
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
阅读排行:
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性
· 全网最简单!3分钟用满血DeepSeek R1开发一款AI智能客服,零代码轻松接入微信、公众号、小程

导航

< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8
点击右上角即可分享
微信分享提示