同类相似文章:Tomcat开启本地库(Apache Tomcat Native Library)支持

服务器环境

uname -a
Linux localhost.localdomain 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)

 

 

 

下载及编译

1、apr

cd /usr/local/src
curl -X GET https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.6.5.tar.gz -o apr-1.6.5.tar.gz 
tar -zxvf apr-1.6.5.tar.gz 

 

 

 

#安装autoconf、libtool、openssl
yum -y install autoconf libtool openssl openssl-devel

 

 

 

 

 

2、 下载apr-util

curl -X GET https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz -o apr-util-1.6.1.tar.gz

 

 

 3、 安装apr和apr-util

/usr/local/src/apr-1.6.5
vim +30993 configure
#然后按下shift + :
#输入 set number
#按两次d删除 $RM "$cfgfile"

参考自:https://www.cnblogs.com/ceyin/p/10695328.html

不删除/注释该行编译的时候报错

config.status: creating test/Makefile
config.status: creating test/internal/Makefile
config.status: creating include/arch/unix/apr_private.h
config.status: executing libtool commands
rm: cannot remove 'libtoolT': No such file or directory

 

 

 编译安装

./configure --prefix=/usr/local/apr

 

 

 

make
make install

 

 

 

 

 

 执行以下命令:

/usr/bin/install -c -m 644 apr.exp /usr/local/apr/lib/apr.exp
/usr/bin/install -c -m 644 apr.pc /usr/local/apr/lib/pkgconfig/apr-1.pc
for f in libtool shlibtool; do \
    if test -f ${f}; then /usr/bin/install -c -m 755 ${f} /usr/local/apr/build-1; fi; \
done
/usr/bin/install -c -m 755 /usr/local/src/apr-1.6.5/build/mkdir.sh /usr/local/apr/build-1
for f in make_exports.awk make_var_export.awk; do \
    /usr/bin/install -c -m 644 /usr/local/src/apr-1.6.5/build/${f} /usr/local/apr/build-1; \
done
/usr/bin/install -c -m 644 build/apr_rules.out /usr/local/apr/build-1/apr_rules.mk
/usr/bin/install -c -m 644 /usr/local/src/apr-1.6.5/build/apr_common.m4 /usr/local/apr/build-1
/usr/bin/install -c -m 644 /usr/local/src/apr-1.6.5/build/find_apr.m4 /usr/local/apr/build-1
/usr/bin/install -c -m 755 apr-config.out /usr/local/apr/bin/apr-1-config

安装apr-util

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

 编译安装tomcat-native

 

cd /script/apache-tomcat-8.5.42/bin/tomcat-native-1.2.21-src/native
sh buildconf --with-apr=/usr/local/src/apr-1.6.5

 

 

./configure --with-apr=/usr/local/apr --with-java-home=$JAVA_HOME --with-ssl=/usr/include/openssl/ --prefix=/script/apache-tomcat-8.5.42
make
make install

 

 

 

 配置环境变量

vim /etc/profile
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apr/lib 
source /etc/profile

 参考来源:https://www.cnblogs.com/zs-notes/p/9496361.html

ant安装方法参见:Centos7安装Ant

编译jar

/script/apache-tomcat-8.5.42/bin/tomcat-native-1.2.21-src
ant compile
ant jar

 

 

 

复制tomcat-native-jar

cp dist/tomcat-native-1.2.21.jar  ../../lib/

修改tomcat环境启动时环境变量

vim bin/setclasspath.sh

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CATALINA_HOME/lib
export CATALINA_HOME=/script/apache-tomcat-8.5.42

 

 

 

 

 

 

重启tomcat

./shutdown.sh
./startup.sh

 

 红色的表示APR启动成功

posted on 2020-01-17 16:48  你不知道的浪漫  阅读(2076)  评论(0编辑  收藏  举报