Tomcat 使用apr优化
一 windows下安装
直接拷贝tcnative-1.dll到TOMCAT_HOME/bin目录下,启动即可
下载地址 http://archive.apache.org/dist/tomcat/tomcat-connectors/native/
二 linux centos4.8或者ubuntu10.10 server安装
1.下载包
到http://apr.apache.org/下载下面3个包
http://apache.fayea.com/apr/apr-1.5.2.tar.gz
http://apache.fayea.com/apr/apr-util-1.5.4.tar.gz
http://apache.fayea.com/apr/apr-iconv-1.2.1.tar.gz
java版本jdk-7u71-linux-x64-rpm.bin
tomcat版本apache-tomcat-7.0.57.tar.gz
三 安装JDK,tomcat
安装JDK并设置环境变量
vi /etc/profile #在他文件末尾处添加下面的变量
# java
JAVA_HOME=/usr/lib/jdk1.7.0_71
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME
export PATH
export CLASSPATH
执行
source /etc/profile
此时环境变量生效果
apache-tomcat-7.0.57.tar.gz解压缩到/data/setup/下面
四 安装apr插件
1)安装apr
tar zxvf apr-1.5.2.tar
cd apr-1.5.2
./configure –prefix=/data/setup/apr
make
make install
2)安装apr-iconv
程序代码
tar -zxvf apr-iconv-1.2.1.tar.gz
cd apr-iconv-1.2.1
./configure -prefix=/data/setup/apr-iconv -with-apr=/data/setup/apr
make
make install
3)安装apr-util
程序代码
tar zxvf apr-util-1.5.4.tar.gz
cd apr-util-1.5.4
./configure -prefix=/data/setup/apr-util -with-apr=/data/setup/apr -with-apr-iconv=/data/setup/apr-iconv/bin/apriconv
make
make install
4)安装tomcat-native
http://archive.apache.org/dist/tomcat/tomcat-connectors/native/1.1.33/source/
程序代码
tar zxvf tomcat-native-1.1.33-src.tar.gz
cd tomcat-native-1.1.33-src/jni/native
./configure -with-apr=/data/setup/apr -with-java-home=/usr/share/java -prefix=/usr/local/tomcat/
make
make install
5)添加环境变量
vi /etc/profile #在他文件末尾处添加下面的变量
# apr
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/data/setup/apr/lib:/usr/local/tomcat/lib
执行
source /etc/profile
此时环境变量生效果
6)修改tomcat配置文件server.xml,protocol=org.apache.coyote.http11.Http11AprProtocol
<Connector port="8081" executor="tomcatThreadPool" protocol="org.apache.coyote.http11.Http11AprProtocol" connectionTimeout="20000" URIEncoding="UTF-8" useBodyEncodingForURI="true" enableLookups="false" redirectPort="8444"/>
启动tomcat
TOMCAT_HOME/bin/start.sh
more TOMCAT_HOME/logs/catalina.out
即可看到
Aug 29, 2010 3:47:32 PM org.apache.catalina.core.AprLifecycleListener init
INFO: Loaded APR based Apache Tomcat Native library 1.5.2.
优化完成