Fixing ApacheBench on OS X Lion

Multithreaded JavaScript has been published with O'Reilly!
DEPRECATED: This post may no longer be relevant or contain industry best-practices.

So, you want to run some website benchmarks from your Mac, do you? Well, good news and bad news. The good news is that your Mac already has it installed, but the bad news is that it is broken. If you've run the command now, you'll probably seen the following error message:

$ ab -n 1 http://www.google.com/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking www.google.com (be patient)...apr_socket_recv: Connection reset by peer (54)</pre>

To fix this, you'll want to run the following commands. In my example, the latest version of Apache is 2.4.3, but by the time you read this it may be a newer version, so just in case, <a href="http://apache.mirrors.pair.com/httpd/" target="_blank">download the latest Apache</a> from their website.

<pre><code class="bash">ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go) # install homebrew
brew install pcre # install PCRE, required by Apache
wget http://apache.mirrors.pair.com/httpd/httpd-2.4.3.tar.bz2 # download Apache
tar -xzvf httpd-2.4.3.tar.bz2 # extract Apache
cd httpd-2.4.3 # enter Apache directory
./configure && make # configure and compile Apache
sudo mv /usr/sbin/ab /usr/sbin/ab.bak # backup old ApacheBench
sudo cp support/ab /usr/sbin/ # install new ApacheBench
ab -n 1 http://www.google.com/ # test new ApacheBench

There ya go! This fixes ApacheBench in OS X Lion. I'm not sure if this also affects Mountain Lion.

ApacheBench Working on OS X Lion
ApacheBench Working on OS X Lion

Tags: #macos #apache
Thomas Hunter II Avatar

Thomas has contributed to dozens of enterprise Node.js services and has worked for a company dedicated to securing Node.js. He has spoken at several conferences on Node.js and JavaScript and is an O'Reilly published author.