對ARP支持,需要安裝以下庫:
- APR library
- JNI wrappers for APR used by Tomcat (libtcnative)
- OpenSSL libraries
其中JNI wrappers(libtcnative)安裝依賴另外兩項,以及Java headers.(It depends on APR, OpenSSL, and the Java headers),也就是:
- APR 1.2+ development headers (libapr1-dev package)
- OpenSSL 0.9.7+ development headers (libssl-dev package)
- JNI headers from Java compatible JDK 1.4+
- GNU development environment (gcc, make)
首先安裝APR和OpenSSL:
$ sudo apt-get install libapr1-dev libssl-dev
但是,這樣安裝APR總是找不着lib,還是手動安裝一下:
1. 下載:
wget http://apache.fayea.com/apache-mirror//apr/apr-1.5.2.tar.gz wget http://apache.fayea.com/apache-mirror//apr/apr-util-1.5.4.tar.gz
或者去網頁下載最新版本:
http://apr.apache.org/download.cgi
2. 解壓:
tar -zxvf apr-1.5.2.tar.gz tar -zxvf aor-util-1.5.4.tar.gz
3. 安裝(使用root賬號,或者每條命令前加sudo):
cd apr-1.5.2 ./configure --prefix=/usr/local/apr make make install cd .. cd apr-util-1.5.4 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr make make insatll
apr默認安裝到/usr/local/apr,所以不加--prefix也可以。apt-util必須加--with-apr,否則找不到apr。
最后安裝JNI wrappers,The wrapper library sources are located in the Tomcat binary bundle, in the bin/tomcat-native.tar.gz
archive.
cd /xxxx/apache-tomcat-xxx/bin tar -zxvf tomcat-native.tar.gz cd tomcat-native-xxx-src/jni/native ./configure --with-apr=/usr/local/apr --with-java-home=/usr/lib/jvm/jdk1.8.0_91 make make install
最后的最后,需要配置環境變量:
vi /etc/profile export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apr/lib
重啟電腦生效。
啟動tomcat,有以下信息,說明APR配置生效:
INFO: Loaded APR based Apache Tomcat Native library 1.1.33 using APR version 1.5.2. ...... INFO: Initializing ProtocolHandler ["http-apr-8080"] ...... INFO: Initializing ProtocolHandler ["ajp-apr-8009"]