Installing mod_bandwidth For the Ultimate in Apache Utilization Control

Installing mod_bandwidth For the Ultimate in Apache Utilization Control

“Mod_bandwidth” is a module for the Apache webserver that enables the setting of server-wide or per connection bandwidth limits, based on the directory, size of files and remote IP/domain. Installing this module involves a number of steps, but it is fairly simple to accomplish.

Reprints and reposting of this article is NOT AUTHORIZED without the express consent of the author. Permission to link to this article from other locations is hereby granted.

SSH into your server as root and perform the following:

mkdir /root/modbw

cd modbw


/usr/local/apache/bin/apxs -c /root/mbw/mod_bandwidth.c -o /usr/local/apache/libexec/
(The above is all one command)

mkdir /usr/local/apache/apachebw

mkdir /usr/local/apache/apachebw/link

mkdir /usr/local/apache/apachebw/master

chown nobody:nobody -R /usr/local/apache/apachebw

pico /etc/httpd/conf/httpd.conf

Find the line that looks like this:

LoadModule rewrite_module libexec/

And BEFORE that line, add this:

LoadModule bandwidth_module libexec/

Then locate the line that looks like this:

AddModule mod_env.c

and BEFORE that line, add this:

AddModule mod_bandwidth.c

Then locate the line that looks like this:

# Document types.

And BEFORE that line add this:

BandWidthDataDir “/usr/local/apache/apachebw”
BandWidthModule On

Then to enable it on a virtual host, locate the virtualhost entry for the
domain you wish to limit and just BEFORE the </virtualhost> line, add

BandWidthModule On
BandWidth all 512

The 512 can be replaced with whatever rate you want to limit it to in
bytes per second.

Save the httpd.conf file.

service httpd restart

cd /usr/sbin


chmod 755


Change $LINKDIR as follows:


Save the file.


pico /etc/rc.d/rc.local

At the end of that file add:

# Launch Cleanlink for mod_bandwidth
perl /usr/sbin/

Save that file.

There is actually a lot more you can do with this module than simply limiting the bandwidth rates. You can limit the number of connections, file sizes and more. I encourage you to read the documentation located here for all the deatils of everything you can sutomize with this module.

Similar Articles : Change All Packages Themes cPanel/WHM, Change All User Themes cPanel/WHM, Official cPanel/WHM Newbies Guide, Updating Apache Using cPanel/WHM Easy Apache, Extended Exim Logging, Linux Apache ASP for cPanel/WHM, How to Hide Bind Version cPanel/WHM, Fix cPanel/WHM Quotas, Disabling Password Reset Option cPanel/WHM, Setting up Private Reseller Name Servers, Installing DrWEB antivirus cPanel/WHM Linux, Properly Reject Invalid Email, Securing /tmp partition, Force Secure Login cPanel/WHM SSL, Default Index cPanel/WHM, Modify Bandwidth Exceeded cPanel/WHM, Use Exiscan to Scan For Viruses, Fix Log Rotation Problems cPanel, Installing mod_bandwidth For the Ultimate in Apache Utilization Control, Linux Distributions, UNIX Flavors (Distributions), Installing and Configuring CSF Firewall