1.安装jre http://www.oracle.com/technetwork/java/javase/下载好jre的tar包
tar -zxvf jre-1.x.tar
2.设置环境变量
vim /etc/profile
JRE_HOME=/data/jre
PATH=$PATH:$JRE_HOME/bin
CLASSPATH=./$JRE_HOME/lib/dt.jar:$JRE_HOME/lib/tools.jar
CATALINA_HOME=/data/tomcat
export JRE_HOME PATH CLASSPATH
3.使环境变量生效
source /etc/profile
4.安装tomcat 下载http://archive.apache.org/dist/tomcat/tomcat-8/
tar -zxvf tomcat-x.x.tar
5.安装apr 下载http://apr.apache.org/
wget http://mirrors.hust.edu.cn/apache/apr/apr-1.5.2.tar.gz
tar -zxvf apr-1.5.2.tar.gz
cd apr-1.5.2
./configure --prefix=/usr/local/apr
make && make install
wget http://apache.fayea.com//apr/apr-iconv-1.2.1.tar.gz
tar -zxvf 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
wget http://apache.fayea.com//apr/apr-util-1.5.4.tar.gz
tar -zxvf 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
wget http://apache.dataguru.cn/tomcat/tomcat-connectors/native/1.1.33/source/tomcat-native-1.1.33-src.tar.gz
tar -zxvf tomcat-native-1.1.33-src.tar.gz
cd tomcat-native-1.1.33-src/jni/native
wget http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.tar.gz
tar -zxvf jdk-8u45-linux-x64.tar.gz
mv jdk-8u45-linux-x64.tar.gz jdk
./configure --with-apr=/usr/local/apr --with-java-home=/data/jdk
make && make install
6.设置apr环境变量
vim /etc/profile
export LD_LIBRARY_PATH=/usr/local/apr/lib
source /etc/profile
7.验证apr成功配置
sh /data/tomcat/bin/start.sh
more /data/tomcat/logs/catalina.out
看到类似这样的信息
Jul 15, 2015 00:27:32 PM org.apache.catalina.core.AprLifecycleListener initINFO: Loaded APR based Apache Tomcat Native library 1.1.30. 即为成功
8.配置tomcat连接数
<Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol"
connectionTimeout="20000"
redirectPort="8443" enableLookups="false" URIEncoding="UTF-8" acceptCount="1000" executor="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="500" minSpareThreads="400"/>
protocol="org.apache.coyote.http11.Http11NioProtocol" 修改成支持NIO的类型
maxThreads="600" //最大线程数
minSpareThreads="100" //初始化时创建的线程数
maxSpareThreads="500" //一旦线程超过这个值,Tomcat会关闭不需要的socket线程
acceptCount="700"//指定当所有可以使用的处理请求的线程数都被使用时,可以放到处理队列中的请求数,超过这个数的请求将不予处理
enableLookups="false"禁用DNS查询
URIEncoding="UTF-8"设置编码