Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Installing mod_bandwidth on Apache UNIX
Uploading large files has an impact on your download speed. To counter this, I spent some time playing with mod_bandwidth this weekend. I am using OS 10.2.3 with Apache 1.3.27

For some reason, the build didn't work for me as per the instructions on the author's website. With a little pushing & pulling, the following worked for me...

  1. Download the file 'mod_bandwidth.c' to your desktop. This is freely available from the download page on the author's site.

  2. Open a terminal type cd Desktop

  3. Type su & give it your password when asked

  4. Type this, with no line breaks, replacing 'mrwalker' with your username: gcc -DDARWIN -DUSE_HSREGEX -DUSE_EXPAT -I../lib/expat-lite -g -Os -pipe -DHARD_SERVER_LIMIT=2048 -DEAPI -DSHARED_MODULE -I/usr/include/httpd -c /Users/mrwalker/Desktop/mod_bandwidth.c

  5. Type this: cc -bundle -undefined suppress -flat_namespace -Wl,-bind_at_load -o /usr/libexec/httpd/ mod_bandwidth.o

  6. You should now have a file /usr/libexec/httpd/ Confirm by typing cd /usr/libexec/httpd, then ls -l. Make it world executable with chmod +x

  7. Add the following lines to /etc/httpd/httpd.conf by typing pico /etc/httpd/httpd.conf. Below all the other LoadModule lines, add LoadModule bandwidth_module /usr/libexec/httpd/ Below all the other AddModule lines, type AddModule mod_bandwidth.c. In the global configuration (or virtual host container if you're using them) add the lines BandWidthModule On and BandWidth all 1024. This will limit the total number of connections to 1024 bytes per second. Change the 1024 as appropriate.

    See the documentation for more config options. I advise adding something like LargeFileLimit 8196 0, which will ignore the limit for files below 8k.

  8. Type Ctrl-o to save the file & Ctrl-x to exit the pico editor.

  9. Add the required temp directories:
     mkdir /tmp/apachebw
    mkdir /tmp/apachebw/link
    mkdir /tmp/apachebw/master
    chmod -R 777 /tmp/apachebw
  10. Restart apache with apachectl restart
If I typed everything right and you followed me, we're done!

[Editor's note: And if I typed everything right while reformatting ... please let me know if you have any troubles with this, as I haven't had time to test it yet.]
  • Currently 2.80 / 5
  You rated: 5 / 5 (5 votes cast)

Installing mod_bandwidth on Apache | 6 comments | Create New Account
Click here to return to the 'Installing mod_bandwidth on Apache' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
If you are uploading via HTTP
Authored by: nvdingo on Feb 05, '03 02:10:47PM

It should be noted more obviously, that if you are uploading a file via ftp, this hint will not do anything for you.

if you are running your own webserver, and have utilities installed such that you are using a web interface to manage your files, then this hint is for you.

The use of mod_bandwidth or mod_throttle on your webserver is handy indeed. Large file uploads will fully saturate your typical 128kbps outgoing bandwidth on your standard DSL or cable modem account, thereby making your browsers requests for downloads get lost in the noise.

[ Reply to This | # ]
throttling via FTP
Authored by: nvdingo on Feb 05, '03 07:52:11PM

if you are using a command line to ftp your files up to any server, check out theman page for ftp

once you have your connection to your server, if you want to limit your upload speed to give your web browser a chance to send out get requests, try this at the ftp prompt
ftp> rate put 8192

the will throttle the rate for outgoing transfers from your machine to 8K/sec
the full list of options for the rate command is:
rate direction [maximum [increment]]
Throttle the maximum transfer rate to maximum bytes/second.
If maximum is 0, disable the throttle.

direction may be one of:
all Both directions.
get Incoming transfers.
put Outgoing transfers.

maximum can by modified on the fly by increment bytes
(default: 1024) each time a given signal is received:

SIGUSR1 Increment maximum by increment bytes.

SIGUSR2 Decrement maximum by increment bytes. The
result must be a positive number.

If maximum is not supplied, the current throttle rates are

Note: rate is not yet implemented for ascii mode transfers.

this is from the man page for FTP that ships with 10.2 from the command line, and may not be supported by various others.

Reading the man page for ftpd can be fun too.
For instance some FTP servers support the SITE RATEPUT and SITE RATEGET commands.
If yours does, and you use Dreamweaver MX, then opening the ftp log window from the window menu, allows you to send raw FTP commands IF YOU ARE CONNECTED.
so if you are putting large files with Dreamweaver, and the server you are connecting too supports it, before you tell DW to put the files, go to the ftp log window and type SITE RATEPUT 8k
this will throttle the connection so that you don't overload your outgoing bandwidth. very handy for doing other things while uploading large files.
sure, it takes longer, but at least you can browse the web efficiently while doing it.

[ Reply to This | # ]
Installing mod_bandwidth on Apache
Authored by: cmyck on Mar 13, '03 05:56:55AM
how would i install other modules like this (i.e. mod_throttle/3.1.2)?

[ Reply to This | # ]
Installing mod_bandwidth on Apache
Authored by: cmyck on Mar 14, '03 10:12:53AM

somehow my /tmp/apachebw directory got deleted.
is there a cron job that delets everthing in the tmp dir when i reboot?
can i put the apachebw somewhere, where it won't get deleted?

if anybody has an answer, please email me: (leave out _nospam_).


[ Reply to This | # ]
Installing mod_bandwidth on Apache
Authored by: jb72 on Apr 19, '03 04:29:50AM

"Somehow my /tmp/apachebw directory got deleted.
is there a cron job that delets everthing in the tmp dir when i
can i put the apachebw somewhere, where it won't get

Mois aussi. The /tmp/apache dirs get hosed. Is there anywhere
else we can put them? Should we make some kind of script to
creste them at boot? What the dillio? if you can help me with this. tia.

[ Reply to This | # ]
Installing mod_bandwidth on Apache
Authored by: kupietz on Apr 28, '07 04:42:05PM
It should be noted, for anyone who comes across this looking for bandwidth-limiting solutions for OS X, that as of v 10.4.6, OS X includes Dummynet, which allows you to do bandwidth limiting without any additional software. See or google for dummynet "os x" for instructions.

[ Reply to This | # ]