WebHostGear.com - the hosting resource for professionalshosting tutorials 
hosting howto webhost guide server managementJuly 23, 2008
server management, apache tutorials, hosting tutorials, cpanel, server security
Home / Hosting Tutorials / cPanel Tutorials / Installing mod_bandwidth For the Ultimate in Apache Utilization Control

Installing mod_bandwidth For the Ultimate in Apache Utilization Control



Printer Friendly Printer Friendly Send to a friend Send to a friend
By : Jon Rating : Average Rating : 6.10 From 10 Voter(s)

"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

wget ftp://ftp.cohprog.com/pub/apache/module/1.3.0/mod_bandwidth.c

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


Article provided by WebHostGear.com
mkdir /usr/local/apache/apachebw



Article provided by WebHostGear.com

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/mod_rewrite.so

And BEFORE that line, add this:

LoadModule bandwidth_module   libexec/mod_bandwidth.so

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
this:

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

wget ftp://ftp.cohprog.com/pub/apache/module/cleanlink.pl

chmod 755 cleanlink.pl

pico cleanlink.pl

Change $LINKDIR as follows:

$LINKDIR="/usr/local/apache/apachebw/link";

Save the file.

perl cleanlink.pl

pico /etc/rc.d/rc.local

At the end of that file add:

# Launch Cleanlink for mod_bandwidth
perl /usr/sbin/cleanlink.pl

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.

 

New! - Need server help? Hire an Expert

Get professional help with your configuration, script installation or server issue.
Learn how we can help you with any server problem and make your server run like new. Professional staff will contact you, after submitting a quote request, by phone or email.

Rate this Article :

1

2

3

4

5

6

7

8

9

10
Poor Excellent

Related Articles


» Official Cpanel Newbie Guide
» Modify Bandwidth Exceeded Page
» Securing Your /tmp Partition with Cpanel/WHM
» Mask Your Web Server for Enhanced Security
» Optimize and Tweak High-Traffic Servers
» Properly Reject Invalid Email
» How to install BFD (Brute Force Detection)
» How to install APF (Advanced Policy Firewall)
» How to install mod_security for Apache
» Apache Log Files Explained
» How to hide bind version - Cpanel
» Linux Apache ASP for Cpanel
» Howto mod_rewrite with Apache
» Updating Apache using Cpanel EasyApache
» Bandwidth Or Data Transfer – Which is Which?


Discuss this article with others in our new hosting forums

Comments / Feedback

Nex
this command is not wright

/usr/local/apache/bin/apxs -c /root/mbw/mod_bandwidth.c -o /usr/local/apache/libexec/mod_bandwidth.so



and this is wright

/usr/local/apache/bin/apxs -c /root/modbw/mod_bandwidth.c -o /usr/local/apache/libexec/mod_bandwidth.so
Aleksandr
mod_bandwidth doesn't affect the php output in mod_php env (we will make tests with phpsuexec soon) - are you aware about php issues? How they could get fixed?

 Add Comment
Name
Email
Image Code
Refresh Image

Comments / Feedback



Web Hosting News RSS ?


WebHostGear Hire an Expert - NEW!
Let us improve your servers performance, find that spammer and take care of that kernel upgrade. Hire us to help with any tutorials listed on the site or any other services needed. Get your free, NO obligation quote now

Our site offers free hosting tutorials, cpanel tutorial, web hosting news, shell commands, running a web hosting business, dedicated guides, linux tutorial, apache install, home web server, web server guide, ssh commands, dedicated servers, DNS nameservers, chkrootkit, apf firewall, exim configuration, server compromised, cron backup solution, ftp backup script

Server Tutorials


WebHostGear Reviewed by Ping Zine - Click here

Special Offer:


Links:
cPanel server administration

MidPhase Coupons

Reseller Hosting

Reseller Hosting FAQ

Icon

Web Hosting

Datacenter Discussion Forum

Lunarpages Coupon

Hosting Coupon



WebhostGear Sponsors
Going Up Advertise Hosting Free Uptime Check Web Hosting Chat Icons Banners Mall