Ubuntu -tomcat9 更换高性能APR模式
- 相关软件
* apr
* apr-iconv
* apr-util
* tomcat-native
下载地址:https://mirrors.cnnic.cn/apache/apr/
- 解压编译
tar xf apr-1.6.3.tar.gz
cd apr-1.6.3/
./configure --prefix=/usr/local/apr
make && make install
cd /usr/local/src
wget https://mirrors.cnnic.cn/apache/apr/apr-iconv-1.2.2.tar.gz
tar xf apr-iconv-1.2.2.tar.gz
cd apr-iconv-1.2.2/
./configure --with-apr=/usr/local/apr --prefix=/usr/local/apr-iconv
make && make install
cd /usr/local/src
wget https://mirrors.cnnic.cn/apache/apr/apr-util-1.6.1.tar.gz
tar xf apr-util-1.6.1.tar.gz
cd apr-util-1.6.1/
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr --with-apr-iconv=/usr/local/apr-iconv/bin/apriconv
make && make install
cd /usr/local/tomcat/bin/
tar xf tomcat-native.tar.gz
cd /usr/local/tomcat/bin/tomcat-native-1.2.16-src/native
./configure --with-apr=/usr/local/apr --with-java-home=/usr/local/jdk8.0
make && make install
echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apr/lib
export LD_RUN_PATH=$LD_RUN_PATH:/usr/local/apr/lib' >> /etc/profile
source /etc/profile
- 修改配置(server.xml)
主要修改Connector 的protocol 属性
<Connector port="80" protocol="org.apache.coyote.http11.Http11AprProtocol"
maxThreads="1000"
minSpareThreads="100"
acceptCount="900"
disableUploadTimeout="true"
connectionTimeout="20000"
URIEncoding="UTF-8"
enableLookups="false"
redirectPort="8443"
compression="on"
compressionMinSize="1024"
/>
<!--不使用ssl就关闭否则启动会报错-->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="off" />