How to Install Apache Benchmark (ab) on CentOS Without Full Apache Package


2 views

When attempting to install Apache Benchmark (ab) on CentOS, many users encounter the frustrating error:

No package httpd-tools available.
Error: Nothing to do

This occurs because modern CentOS/RHEL distributions package the benchmarking tool separately from the main Apache httpd server.

The proper way to install just the benchmarking tool is:

sudo yum install -y httpd-tools

If this fails with "No package available", you'll need to verify your repositories:

sudo yum repolist all
sudo yum clean all
sudo yum makecache

For CentOS 8+ or when facing repository issues:

sudo dnf install httpd-tools

If you absolutely need just the 'ab' binary without dependencies:

sudo yum install --downloadonly --downloaddir=. httpd-tools
rpm2cpio httpd-tools-*.rpm | cpio -idmv ./usr/bin/ab

After successful installation, test with:

ab -V
ab -n 100 -c 10 http://example.com/

Sample output should show:

This is ApacheBench, Version 2.3

If you see "command not found" after installation:

export PATH=$PATH:/usr/bin
which ab

For repository configuration issues:

sudo yum install epel-release
sudo yum update

Here's a comprehensive benchmark test:

ab -n 5000 -c 100 -k -H "Accept-Encoding: gzip" \
  -e results.csv https://yoursite.com/api/endpoint

Parameters explained:

  • -n 5000: Total requests
  • -c 100: Concurrent requests
  • -k: Keep-alive connections
  • -H: Add request header
  • -e: Export results to CSV

When attempting to install Apache Benchmark on CentOS, many users encounter the "No package available" error. This commonly occurs because:

  • The default CentOS repositories don't include httpd-tools as a separate package in some versions
  • The EPEL repository isn't enabled on your system
  • Package names differ between CentOS versions

Here are three working approaches depending on your CentOS version:

Method 1: For CentOS 7/RHEL 7

# Install EPEL first if not present
yum install epel-release -y

# Then install httpd-tools
yum install httpd-tools -y

Method 2: For CentOS 8/RHEL 8

dnf install httpd-tools -y

Method 3: Manual Download (When Repositories Fail)

# Find the exact package URL from CentOS vault
wget http://vault.centos.org/7.9.2009/os/x86_64/Packages/httpd-tools-2.4.6-97.el7.centos.x86_64.rpm

# Install with dependencies
yum localinstall httpd-tools-2.4.6-97.el7.centos.x86_64.rpm

After successful installation, verify ab is working:

ab -V
# Should output version info like:
# This is ApacheBench, Version 2.3 <$Revision: 1879490 $>

Basic load test against a web server:

ab -n 1000 -c 50 http://example.com/

Testing with custom headers:

ab -n 500 -c 20 -H "Authorization: Bearer token123" http://api.example.com/v1/users

For HTTPS endpoints:

ab -n 1000 -c 100 -k https://secure.example.com/

Key metrics to watch in ab output:

  • Requests per second: Throughput capability
  • Time per request: Latency measurement
  • Failed requests: Stability indicator

Example benchmark analysis:

Concurrency Level:      100
Time taken for tests:   2.305 seconds
Complete requests:      1000
Failed requests:        0
Requests per second:    433.84 [#/sec] (mean)
Time per request:       230.492 [ms] (mean)

If you still can't locate the package:

# Search all available packages
yum list available | grep -i httpd

# Check enabled repositories
yum repolist all

# Clean yum cache
yum clean all