首页 > 分享 > Apache安装apr和apr

Apache安装apr和apr

最新推荐文章于 2024-06-05 08:48:44 发布

原创 于 2018-02-27 15:24:05 发布 · 1.3w 阅读

· 3

· 11 ·

CC 4.0 BY-SA版权

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

要测APR给tomcat带来的好处最好的方法是在慢速网络上(模拟Internet),将Tomcat线程数开到300以上的水平,然后模拟一大堆并发请求。如果不配APR,基本上300个线程狠快就会用满,以后的请求就只好等待。但是配上APR之后,并发的线程数量明显下降,从原来的300可能会马上下降到只有几十,新的请求会毫无阻塞的进来。APR对于Tomcat最大的作用就是socket调度。你在局域网环境测,就算是400个并发,也是一瞬间就处理/传输完毕,但是在真实的Internet环境下,页面处理时间只占0.1%都不到,绝大部分时间都用来页面传输。如果不用APR,一个线程同一时间只能处理一个用户,势必会造成阻塞。所以生产环境下用apr是非常必要的。

具体安装步骤

下载APR相关

wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.6.3.tar.gz wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-iconv-1.2.2.tar.gz wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz #获取运行tomcat(无论内置还是外置,对应tomcat版本下的/bin/tomcat-native.tar.gz 目前版本为1.2.14) tar zxvf apr-1.6.3.tar.gz tar zxvf apr-util-1.6.1.tar.gz tar zxvf apr-iconv-1.2.2.tar.gz tar zxvf tomcat-native.tar.gz

plain

安装APR

cd apr-1.6.3 ./configure --prefix=/usr/local/apr make && make install cd apr-iconv-1.2.2 ./configure --prefix=/usr/local/apr-iconv --with-apr=/usr/local/apr make && make install 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 tomcat-native-1.2.14-src/native ./configure --prefix=/usr/local/apr --with-java-home=/usr/local/jdk1.8.0_131/ #若报类似#include <expat.h>错误,需yum安装expat: yum install expat-devel make && make install #注意:要求系统OpenSSL library version >= 1.0.2 #若版本太低,安装native会报错。 openssl version #以下是安装openssl操作。若版本已达到1.0.2可以不用参考。 ######################################################### 下载openssl wget https://www.openssl.org/source/openssl-1.0.2j.tar.gz tar zxvf openssl-1.0.2j.tar.gz cd openssl ./config --prefix=/usr/local/openssl -fPIC make && make install mv /usr/bin/openssl ~ //备份 ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl //替换最新openssl执行文件 openssl version //查看openssl版本是否已替换 #安装成功后,可再次执行tomcat-native

plain

配置环境变量

vi /etc/profile #添加:export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apr/lib vi /etc/bashrc #添加:export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apr/lib source /etc/profile source /etc/bashrc

plain


@Configuration

public class AprConfiguration {

@Value("${server.tomcat.apr.enabled:false}")

private boolean enabled;

@Bean

public EmbeddedServletContainerFactory servletContainer() {

TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();

if (enabled) {

AprLifecycleListener aprLifecycle = new AprLifecycleListener();

aprLifecycle.setSSLEngine("off");

container.setProtocol("org.apache.coyote.http11.Http11AprProtocol");

container.addContextLifecycleListeners(aprLifecycle);

}

return container;

}

}

java

运行

server.tomcat.accept-count=3000

server.tomcat.max-threads=1000

server.tomcat.max-connections=1000

server.tomcat.apr.enabled=true

java

运行

参考:http://blog.51cto.com/wgkgood/432272

相关知识

永恒之柱2死火官方全隐藏代码一览 隐藏代码使用方法介绍
谷歌云搭建wordpress centos7 + apache + mysql + php + wordpress
宠物坐飞机旅行:我和狗狗的低成本之旅
springboot+html宠物医院诊疗系统(源码+lw+部署文档+讲解等)
我和它的最美邂逅:关于宠物的几个故事
基于Springboot的宠物医院管理系统
Reptile Feeding Box Tortoise Guarding House Pet Incubator Hamster Crawling Pet Constant Temperature Heating Box Small Pet Cages - Buy Large Hamster Cage reptile Breeding Box acrylic Reptile Terrarium Cage Product on Alibaba.com
米域公益
奇闻异事:一只宠物猪引发的夫妻大战!
悦动型麻醉机/宠物麻醉机—瑞沃德

网址: Apache安装apr和apr https://m.mcbbbk.com/newsview1338206.html

所属分类:萌宠日常
上一篇: sharding
下一篇: MQTT C Cient的实现