在使用ApacheBench做压力测试的时候出现30s
request超时的情况,由于版本老旧,ab -h
中发现并没有-s timeout
的参数配置,Google上找了半天也没有可用的Binaries版本,于是开始自己编译httpd源码
针对于ab timeout的问题(报错:The timeout specified has expired (70007)),加了
-k
参数保证keepalived参数也无用,在2.4.4+版本中加入了-s
参数控制timeout;
1 | -s timeout |
SoftWare | Version |
---|---|
Ubuntu Server x64 | 14.04 |
pcre | 8.38 |
apr-util | 1.6.1 |
apr | 1.6.5 |
httpd | 2.4.38 |
gcc & gcc-c++ | 5.4.0 |
gcc & gcc-c++ 系统自带;如果自己本机没有需要先install下
pcre 编译
1 | unzip pcre-8.38.zip |
注意在make 失败后,一定要使用make clean命令清空环境
错误1
1 | xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory |
解决
Centos安装:yum install expat-devel
ubuntu安装:sudo apt-get install libexpat1-dev
apr & apr-util 编译
准备工作
1 | tar -zxvf apr-util-1.6.1.tar.gz |
apr 编译
1 | # apr 编译 |
apr-util 编译
1 | # apr 编译 |
httpd 编译
1 | cd httpd-2.4.38 |
错误2
1 | recipe for target 'htpasswd' failed |
解决
是因为apr、apr-util
源码没有在httpd-2.4.38/srclib/
目录下,cp过去就可以(注意:只需目录名,无需版本号)
测试安装成功
- ApacheBench 测试
1 | # 发现已经有了 -s 参数 |
- 服务测试
1 | sudovim /usr/local/apache-httpd/conf/httpd.conf |
转载请注明出处:https://github.com/imperio-wxm