Installing mod_bandwidth on Apache

Feb 05, '03 09:52:02AM

Contributed by: mrwalker

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...

Instructions:

  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.so mod_bandwidth.o

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

  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/mod_bandwidth.so. 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.]

Comments (6)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20030205065202355