2019独角兽企业重金招聘Python工程师标准>>>
由于ab是Apache自带的压测工具,所以安装好apache的httpd即可
第一步: 安装apache
AT7730:~ yangchuanhuan$ sudo port install apache2
....
60 from https://packages.macports.org/apache2
---> Installing apache2 @2.2.31_2+preforkmpm
---> Activating apache2 @2.2.31_2+preforkmpm
---> Cleaning apache2
---> Updating database of binaries
---> Scanning binaries for linking errors
---> No broken files found.
说明安装成功
第二步: 下载并安装httpd
首先下载httpd,打开网址:http://ftp.yz.yamagata-u.ac.jp/pub/network/apache/httpd/
可以看到Apache httpd的系统版本信息,
找到最新版本:
httpd-2.2.32.tar.bz2 2017-01-13 03:38 5.5M HTTP Server project
下载到本地,然后进入到下载压缩包所在的目录:
AT7730:~ yangchuanhuan$ cd /Users/yangchuanhuan/Downloads/
AT7730:Downloads yangchuanhuan$ tar -zxvf httpd-2.2.32.tar.bz2
解压完成后,进入解压后的目录
AT7730:Downloads yangchuanhuan$ cd httpd-2.2.32
AT7730:httpd-2.2.32 yangchuanhuan$ ./configure
如果出现如下错误信息
Making install in prefork
Making install in modules
Making install in aaa
mkdir /usr/local/apache2
mkdir: /usr/local/apache2: Permission denied
mkdir /usr/local/apache2/modules
mkdir: /usr/local/apache2: No such file or directory
make[3]: *** [install-modules-yes] Error 1
make[2]: *** [install-recursive] Error 1
make[1]: *** [install-recursive] Error 1
make: *** [install-recursive] Error 1
说明没有权限创建apache2和apache2/modules文件夹
手动创建这两个文件夹,并将apache2文件夹所有者修改为当前用户
AT7730:local yangchuanhuan$ sudo mkdir apache2
AT7730:local yangchuanhuan$ cd apache2/
AT7730:apache2 yangchuanhuan$ mkdir modules
AT7730:local yangchuanhuan$ sudo chown -R yangchuanhuan apache2
然后再执行
AT7730:httpd-2.2.32 yangchuanhuan$ ./configure
AT7730:httpd-2.2.32 yangchuanhuan$ sudo make && make install
至此httpd已经安装成功了,
AT7730:httpd-2.2.32 yangchuanhuan$ cd support/
AT7730:support yangchuanhuan$ 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
......
说明ab已经可以正常使用了