因为ab是Apache自带的压测工具,因此安装好apache的httpd便可apache
第一步: 安装apache工具
AT7730:~ yangchuanhuan$ sudo port install apache2spa
....orm
60 from https://packages.macports.org/apache2ip
---> Installing apache2 @2.2.31_2+preforkmpmget
---> Activating apache2 @2.2.31_2+preforkmpmrequests
---> Cleaning apache2it
---> Updating database of binariesio
---> Scanning binaries for linking errors form
---> 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已经能够正常使用了