ab 是apache对 http服务器进行压力测试的工具,它可以测试出服务器每秒可以处理多少请求。本文记录mac版本安装 ab 的步骤以及遇到的坑。

下载

进入 apache ab官网 下载页面。

安装

brew 安装

  • 因为笔者的操作系统是mac系统,所以需要先安装brew。进入brew网站。执行下方命令
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

执行命令后报错:

Failed to connect to raw.githubusercontent.com port 443: Connection refused

解决方案:

打开 https://www.ipaddress.com/ 查询 raw.githubusercontent.com 对应的 ip 地址。

添加ip到 /etc/hosts,添加以下配置:

185.199.108.133 raw.githubusercontent.com
185.199.109.133 raw.githubusercontent.com
185.199.110.133 raw.githubusercontent.com
185.199.111.133 raw.githubusercontent.com

再执行

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

执行成功后,使用brew安装apr、apr-util和prce

brew install apr
brew install apr-util
brew inatll prce

apache ab安装

解压下载后压缩包,进入 httpd-2.4.51 目录。

执行以下命令:

./configure
make
make install

执行 ./configure 命令时报错:

jeremy@jeremydeMacBook-Pro httpd-2.4.51 % ./configure
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking build system type... x86_64-apple-darwin20.2.0
checking host system type... x86_64-apple-darwin20.2.0
checking target system type... x86_64-apple-darwin20.2.0
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... no
configure: error: APR not found. Please read the documentation.

APR not found 没找到

./configure 改成

 ./configure --with-apr=/usr/local/opt/apr --with-apr-util=/usr/local/opt/apr-util --with-pcre=/usr/local/Cellar/pcre/8.45

其中 pcre 的路径可能不同,需要在 /usr/local/Cellar/pcre 里面确定路径。

上述命令执行成功后,如果没有报错,表明安装成功,执行ab

ab: wrong number of arguments
Usage: ab [options] [http[s]://]hostname[:port]/path
Options are:
-n requests Number of requests to perform
-c concurrency Number of multiple requests to make at a time
-t timelimit Seconds to max. to spend on benchmarking
This implies -n 50000
-s timeout Seconds to max. wait for each response
Default is 30 seconds
-b windowsize Size of TCP send/receive buffer, in bytes
-B address Address to bind to when making outgoing connections
-p postfile File containing data to POST. Remember also to set -T
-u putfile File containing data to PUT. Remember also to set -T
-T content-type Content-type header to use for POST/PUT data, eg.
'application/x-www-form-urlencoded'
Default is 'text/plain'
-v verbosity How much troubleshooting info to print
-w Print out results in HTML tables
-i Use HEAD instead of GET

出现以上界面,说明 ab 已经安装成功。

运行 ab

主要参数

  • -n 请求树
  • -c 并发数(访问人数)
  • -t 请求时间最大数
ab -n 1000 -c 100 http://www.baidu.com

表示请求baidu.com 使用100请求数,请求1000次。

总结

  • 需要在配置brew和检测configure上花了比较多的时间。
  • 其余的按照步骤即可。

MAC 安装 apache ab 压力测试工具以及遇到的坑的更多相关文章

  1. [转] CentOS单独安装Apache Benchmark压力测试工具的办法

    Apache安装包中自带的压力测试工具 Apache Benchmark(简称ab) 简单易用,这里就采用 ab作为压力测试工具了. 1.独立安装 ab运行需要依赖apr-util包,安装命令为: 1 ...

  2. apache ab 压力测试工具

    Apache的ab命令模拟多线程并发请求,测试服务器负载压力,也可以测试nginx.lighthttp.IIS等其它Web服务器的压力.Apache附带的ab工具(使用的PHP环境是WAMP集成环境, ...

  3. CentOS7安装使用ab压力测试工具

    执行安装命令:yum -y install httpd-tools 安装完毕,执行:ab -help,显示命令参数 命令模板:ab -c 100 -n 10000 待测试网站(建议完整路径) -c 即 ...

  4. CentOS7单独安装Apache Bench压力测试工具

    用于并发测试. 1.安装 # need to run ab,apache portable runtime yum install apr-util # yum install yum-utils # ...

  5. 4分钟apache自带ab压力测试工具使用: 2015.10.4

    2015.10.44分钟apache自带ab压力测试工具使用:win8.1 wampserver2.5 -Apache-2.4.9-Mysql-5.6.17-php5.5.12-64b 可以参考一下部 ...

  6. win8.1上wamp环境中利用apache自带ab压力测试工具使用超简单讲解

    2015.10.4apache自带ab压力测试工具使用:本地环境:win8.1 wampserver2.5 -Apache-2.4.9-Mysql-5.6.17-php5.5.12-64b 可以参考一 ...

  7. apache ab压力测试报错(apr_socket_recv: Connection reset by peer (104))

    apache ab压力测试报错(apr_socket_recv: Connection reset by peer (104))   今天用apache 自带的ab工具测试,当并发量达到1000多的时 ...

  8. apache ab压力测试报错apr_socket_recv

    apache ab压力测试报错(apr_socket_recv: Connection reset by peer (104)) apache 自带的ab工具测试,当并发量达到1000多的时候报错如下 ...

  9. Apache中压力测试工具ab的操作说明

    1.压力测试工具ab(ApacheBench)的简单说明 1)     网站性能压力测试是性能调优过程中必不可少的一环.只有让服务器处在高压情况下才能真正体现出各种设置所暴露的问题.Apache中有个 ...

随机推荐

  1. 机器学习之支持向量机(python)

    参考链接:https://blog.csdn.net/weixin_33514582/article/details/113321749.https://blog.csdn.net/weixin_44 ...

  2. error: object file .git/objects/...

    cd .git find . -type f -empty -delete -print tail -n 2 .git/logs/refs/heads/master git show xxxx(版本号 ...

  3. JS008. 跳转缓存滚动条高度并返回时过渡动画(window.pageYOffset & window.scrollTo & SessionStorage)

    业务场景 从列表跳转详情页,通过操作返回列表页时,滚动条仍然处于跳转前的高度,并加上 ease-out 的过渡动画. 由于sessionStorage是随页面即关即消的,所以比起VUEX.localS ...

  4. vim中字符串的替换

    vi/vim 中可以使用 :s 命令来替换字符串 :s/vivian/sky/ 替换当前行第一个 vivian 为 sky :s/vivian/sky/g 替换当前行所有 vivian 为 sky : ...

  5. Mac上Markdown的使用

    Markdown是什么,且听我快快道来. 20年前,我第一次接触互联网,当时还是用 28.8k的猫拨号. 我从一本<电脑报>附赠的光盘里,找到了 台湾版的"烘培机"(烘 ...

  6. 论文解读《Momentum Contrast for Unsupervised Visual Representation Learning》俗称 MoCo

    论文题目:<Momentum Contrast for Unsupervised Visual Representation Learning> 论文作者: Kaiming He.Haoq ...

  7. ❤️【Android精进之路-01】定计划,重行动来学Android吧❤️

    您好,我是码农飞哥,感谢您阅读本文,欢迎一键三连哦. Android精进之路第一篇,确定安卓学习计划. 干货满满,建议收藏,需要用到时常看看.小伙伴们如有问题及需要,欢迎踊跃留言哦~ ~ ~. 前言 ...

  8. css3 flex的IE8浏览器兼容问题

    我这是进行判断浏览器 css判断ie版本才引用样式或css文件 <!--[if !IE]><!--> 除IE外都可识别 <!--<![endif]--> &l ...

  9. npm WARN ajv-keywords@2.1.1 requires a peer of ajv@^5.0.0 but none is installed. You must install peer dependencies yourself.

    解决: npm install -g npm-install-peers npm install -g npm npm i ajv 但是好像没啥用

  10. Linux系列(7) - 链接命令

    硬链接 拥有相同的i节点和存储block块,可以看做事同一个文件 可通过i节点识别 不能跨分区 不能针对目录使用,只能针对文件 软链接 类似Windows快捷方式 软链接拥有自己的i节点和block块 ...