cetos7.0环境下启动tomcat8,报如下错误
Tomcat ans APR lib : requires the APR/native library which is not available
查看tomcat配置文件service.xml
<Connector port="18702" protocol="org.apache.coyote.http11.Http11AprProtocol"
connectionTimeout="20000"
redirectPort="8443"
maxThreads="500"
minSpareThreads="20"
acceptCount="100"
disableUploadTimeout="true"
enableLookups="false"
URIEncoding="UTF-8"/>
这是因为配置里面指定使用协议是org.apache.coyote.http11.Http11AprProtocol,即需要用APR运行模式,但这并不是tomcat默认的运行模式(此外还有bio和nio模式),需要额外安装apr和native的包才行。
需要安装以下几个包
- openssl-1.0.2(支持http2.0的话需要1.0.2以上版本,此处安装的openssl-1.0.2k)
- apr
- apr-util
- tomcat-native(这个包在tomcat的bin目录下带的有)
安装过程
1、安装openssl
tar xzvf openssl-1.0.2k.tar.gz
cd openssl-1.0.2k
./config --prefix=/usr/local/openssl --shared
make
make test
make install
mv /usr/bin/openssl /usr/bin/openssl.OFF
mv /usr/include/openssl /usr/include/openssl.OFF
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
echo "/usr/local/openssl/lib">>/etc/ld.so.conf
ldconfig -v
openssl version -a
2、安装apr
tar -zxvf apr-1.5.2.tar.gz
cd apr-1.5.2
./configure --prefix=/usr/local/apr
make
make install
3、安装apr-util
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
4、安装tomcat-native
cd ****** #tomcat安装路径
tar -zxvf tomcat-native.tar.gz
cd tomcat-native-1.2.10-src/native
./configure --with-apr=/usr/local/apr --with-java-home=/opt/jdk1.7.0_67 --with-ssl=/usr/local/openssl
make
make install