1.下载包
到http://apr.apache.org/下载下面3个包
apr-1.6.3.tar.gz
apr-iconv-1.2.2.tar.gz
apr-util-1.6.1.tar.gz
下载地址 http://archive.apache.org/dist/tomcat/tomcat-connectors/native/
需要的几个环境
#yum -y install autoconf // 安装autoconf
#yum -y install libtool // 安装libtool
#yum -y install openssl openssl-devel // 安装openssl
1)安装apr
tar zxvf apr-1.6.3.tar.gz
cd apr-1.6.3
./configure --prefix=/usr/local/apr
make
make install
2)安装apr-util
tar zxvf apr-util-1.6.1.tar.gz
cd apr-util-1.6.1
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make
make install
执行make报错
make[1]: Entering directory `/root/Downloads/apache_svn/apr-util-1.6.0'
/bin/sh /usr/local/apr/build-1/libtool --silent --mode=compile gcc -g -O2 -pthread -DHAVE_CONFIG_H -DLINUX -D_REENTRANT -D_GNU_SOURCE -I/root/Downloads/apache_svn/apr-util-1.6.0/include -I/root/Downloads/apache_svn/apr-util-1.6.0/include/private -I/usr/local/apr/include/apr-1 -o xml/apr_xml.lo -c xml/apr_xml.c && touch xml/apr_xml.lo
xml/apr_xml.c:35:19: error: expat.h: No such file or directory
xml/apr_xml.c:66: error: expected specifier-qualifier-list before ‘XML_Parser’
xml/apr_xml.c: In function ‘cleanup_parser’:
xml/apr_xml.c:364: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:365: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c: At top level:
xml/apr_xml.c:384: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token
xml/apr_xml.c: In function ‘apr_xml_parser_create’:
xml/apr_xml.c:401: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:402: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:410: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:411: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:412: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:424: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:424: error: ‘default_handler’ undeclared (first use in this function)
xml/apr_xml.c:424: error: (Each undeclared identifier is reported only once
xml/apr_xml.c:424: error: for each function it appears in.)
xml/apr_xml.c: In function ‘do_parse’:
xml/apr_xml.c:434: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:438: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:442: error: ‘apr_xml_parser’ has no member named ‘xp_err’
xml/apr_xml.c:442: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c: In function ‘apr_xml_parser_geterror’:
xml/apr_xml.c:500: error: ‘apr_xml_parser’ has no member named ‘xp_err’
xml/apr_xml.c:500: error: ‘apr_xml_parser’ has no member named ‘xp_err’
make[1]: * [xml/apr_xml.lo] Error 1
make[1]: Leaving directory `/root/Downloads/apache_svn/apr-util-1.6.0'
make: * [all-recursive] Error 1
解决办法:
yum install expat-devel
或者下载安装expat库
http://download.chinaunix.net/download/0003000/2844.shtml
3)安装 tomcat-native组件
tar zxvf tomcat-native-1.2.17-src.tar.gz
cd tomcat-native-1.2.17-src/native
./configure --with-apr=/usr/local/apr
//出现如下错误 //Found OPENSSL_VERSION_NUMBER 0x1000105f (OpenSSL 1.0.1e 11 Feb 2013) //Require OPENSSL_VERSION_NUMBER 0x1000200f or greater (1.0.2) //configure: error: Your version of OpenSSL is not compatible with this version of tcnative
configure: error: Your version of OpenSSL is not compatible with this version of tcnative
由于centos 7 当前的yum 库只有1.0.1 的OpenSSL,所以我们需要手工安装1.0.2
# wget https://www.openssl.org/source/openssl-1.0.2-latest.tar.gz
# tar -xzxf openssl-1.0.2-latest.tar.gz
# cd openssl-1.0.2o
# ./config --prefix=/usr/local/openssl -fPIC // 注意这里需要加入 -fPIC参数,否则后面在安装tomcat native 组件会出错 /
/ 注意:不要按照提示去运行 make depend
# make
# make install
# mv /usr/bin/openssl ~
# ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
# openssl version
// 确认版本信息是1.0.2
4)重新安装 tomcat-native组件
cd tomcat-native-1.2.17-src/native
./configure --with-apr=/usr/local/apr --with-ssl=/usr/local/openssl
make & make install
5)添加环境变量
vi /etc/profile #在他文件末尾处添加下面的变量
# apr
export LD_LIBRARY_PATH=/usr/local/apr/lib
执行
source /etc/profile
此时环境变量生效果
将server.xml将protocol从HTTP/1.1改成org.apache.coyote.http11.Http11AprProtocol(tomcat8以下版本)
启动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.1.20.
优化完成