安装Tomcat的Apr
转:http://www.cnblogs.com/littlehb/archive/2013/04/02/2994785.html
安装Tomcat的Apr,提升性能
发现 Tomcat 可以用 Apache Portable Runtime 来提供更强性能,提升Web静态页面的处理能力,不再需要专门的Web Server来处理静态页面了。
apr 与 tomcat-native 提供更好的伸缩性、性能和集成到本地服务器技术。
如果没有apr技术,启动tomcat 时出现如下提示:
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/jdk1.6.0_06/jre/lib/i386/client:/usr/java/jdk1.6.0_06/jre/lib/i386:/usr/java/jdk1.6.0_06/ jre/../lib/i386:/usr/java/packages/lib/i386:/lib:/usr/lib
按照官方说明需要:
APR library
OpenSSL libraries
openssl 可以用
yum install -y openssl-devel
apr还是下载*.gz来安装。
(0)安装gcc
yum install gcc -y
(1)安装apr
cd /data wget http://mirrors.cnnic.cn/apache//apr/apr-1.5.2.tar.gz tar zxf apr-1.5.2.tar.gz cd apr-1.5.2 ./configure --prefix=/usr/local/apr make && make install
(2)安装apr-iconv
cd /data wget http://mirrors.cnnic.cn/apache//apr/apr-iconv-1.2.1.tar.gz tar zxf apr-iconv-1.2.1.tar.gz cd apr-iconv-1.2.1 ./configure --prefix=/usr/local/apr-iconv --with-apr=/usr/local/apr make && make install
(3)安装apr-util
cd /data wget http://mirrors.cnnic.cn/apache//apr/apr-util-1.5.4.tar.gz tar zxf apr-util-1.5.4.tar.gz cd apr-util-1.5.4 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr --with-apr-iconv=/usr/local/apr-iconv/bin/apriconv make && make install
(4)安装tomcat-native
cd /data/tomcat/bin/ tar zxf tomcat-native.tar.gz cd tomcat-native-1.1.33-src cd jni/native/ ./configure --with-apr=/usr/local/apr make && make install
(5)设置 apr 的环境变量
cd /data/tomcat/bin
vi catalina.sh
添加下面的代码
#!/bin/sh LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apr/lib export LD_LIBRARY_PATH
(6)设置 tomcat 的连接器 Http11AprProtocol
cd /data/tomcat/conf
vim server.xml
修改Connector的protocol属性值
<Connector port="80" protocol="org.apache.coyote.http11.Http11AprProtocol"