How to Install Apache Benchmark on CentOS (bash: ab command not found)

Because I’m keep forgetting this and probably many of you might also need this info, I decided to post it on my blog. Lately I was doing some benchmark tests on different servers. On one of the servers (running on CENTOS 6.8) I was using the Apache Benchmarking tool and was getting this error:

bash: ab command not found

After doing some investigation and online research I found out httpd was missing so I tried to install it. The installation failed. From further investigation I found out that I have to editing the yum.conf file.

I’m a web developer, but don’t have much experience with configuring servers, so it took me a while to figure everything out. Anyways, I will show you step by step what you should do in order to install AB benchmark on your CENTOS 6.8 server:

Connect via SSH to the server using Putty.

Run the following command to configure yum.conf

vi /etc/yum.conf

The Result

exclude=bind-chroot courier* dovecot* exim* filesystem httpd* mod_ssl* mydns* mysql* nsd* php* proftpd* pure-ftpd* spamassassin* squirrelmail*

Now you have to remove http* from the exclude list.

Type the following command to save and exit:

:wq

Now install httpd using the following command line:

yum -y install httpd

This will take few seconds and will get a notification whether the installation was successful or not. After installing httpd you need to run the following command for benchmarking:

ab -n 1000 -c 10 http://google.com/

The result:

Benchmarking google.com (be patient).....done

Server Software:        gws

Server Hostname:        google.com

Server Port:            80

Document Path:          /

Document Length:        219 bytes

Concurrency Level:      10

Time taken for tests:   0.030 seconds

Complete requests:      10

Failed requests:        0

Write errors:           0

Non-2xx responses:      10

Total transferred:      5400 bytes

HTML transferred:       2190 bytes

Requests per second:    332.06 [#/sec] (mean)

Time per request:       30.115 [ms] (mean)

Time per request:       3.011 [ms] (mean, across all concurrent requests)

Transfer rate:          175.11 [Kbytes/sec] received

Connection Times (ms)

min  mean[+/-sd] median   max

Connect:        1    1   0.3      1       1

Processing:    13   14   0.4     14      14

Waiting:       13   14   0.5     14      14

Total:         13   15   0.6     15      16

Percentage of the requests served within a certain time (ms)

50%     15

66%     15

75%     15

80%     15

90%     16

95%     16

98%     16

99%     16

100%     16 (longest request)

Done!

Hope this has helped you and next time if I forget how to install the AB (Apache Benchmark) on a web server, this tutorial will help me remember.

Share on FacebookShare on Google+Tweet about this on TwitterShare on RedditShare on StumbleUponShare on LinkedIn

Leave a Comment

Your email address will not be published. Required fields are marked *