{"id":195,"date":"2010-01-20T13:13:53","date_gmt":"2010-01-20T06:13:53","guid":{"rendered":"http:\/\/www.jfdesignnet.com\/?p=195"},"modified":"2010-01-20T13:13:53","modified_gmt":"2010-01-20T06:13:53","slug":"bandwidth-limitter-using-mod_bw-module-with-apache","status":"publish","type":"post","link":"https:\/\/www.jfdesignnet.com\/?p=195","title":{"rendered":"Bandwidth limitter using mod_bw module with apache"},"content":{"rendered":"<p>Running a webserver with a lot quantity of virtual server is a double-edged sword. The more hosted site, the more income for us, but for every ten legitimate users, there&#8217;s at least one greed user that wants the whole site traffic. This is bad enough under normal circumstances, but it&#8217;s even worse when we&#8217;re on a co-hosted link and\/or a shared server co-operation, because this will ruins the experience for the other clients AND the other servers on the same link.<\/p>\n<p>Such was the situation on one of my server the other day, when I was recently made aware that one of the virtual servers was generating the vast majority of network traffic on a shared server on a shared network. I scanned quickly for runaway\/zombie procs and found nothing, except an unusually large number of delay when opening one of the hosted site.<\/p>\n<p>Well, I have to find a way how to limit that &#8220;greedy&#8221; user without too much modification made to the server itself because this is one is our main production server. So I started to google around for bandwitdh throttling measures that are spesific to web traffic, and I came across <a title=\"mod_bw\" href=\"http:\/\/www.ivn.cl\/apache\/\">bw_mod<\/a> by Ivan &#8220;Bruce&#8221; Barrera. It, along with a couple of built-in directives within apache, look to be the easiest solution to my problem, and here&#8217;s how I implemented them.<\/p>\n<p>This mod_bw needs recompile the module using apxs2, so we need apache devel package to do that, install this using apt source from cdrom (to make sure I&#8217;ve got the same version libaprutil1 package along with my running apache package) :<\/p>\n<blockquote><p>komodo:\/home\/jfdesign# apt-get install libaprutil1-dev<br \/>\nReading package lists&#8230; Done<br \/>\nBuilding dependency tree<br \/>\nReading state information&#8230; Done<br \/>\nThe following packages were automatically installed and are no longer required:<br \/>\ncourier-ssl courier-base courier-authlib-userdb<br \/>\nUse &#8216;apt-get autoremove&#8217; to remove them.<br \/>\nThe following extra packages will be installed:<br \/>\ncomerr-dev libapr1-dev libdb4.6-dev libexpat1-dev libkadm55 libkrb5-dev libldap2-dev libpcre3-dev libpcrecpp0 libpq-dev<br \/>\nlibsqlite3-dev libssl-dev uuid-dev<br \/>\nSuggested packages:<br \/>\ndoc-base db4.6-doc krb5-doc postgresql-doc-8.3 sqlite3-doc<br \/>\nThe following NEW packages will be installed:<br \/>\ncomerr-dev libapr1-dev libaprutil1-dev libdb4.6-dev libexpat1-dev libkadm55 libkrb5-dev libldap2-dev libpcre3-dev libpcrecpp0<br \/>\nlibpq-dev libsqlite3-dev libssl-dev uuid-dev<br \/>\n0 upgraded, 14 newly installed, 0 to remove and 0 not upgraded.<br \/>\nNeed to get 0B\/6122kB of archives.<br \/>\nAfter this operation, 20.7MB of additional disk space will be used.<br \/>\nDo you want to continue [Y\/n]? y<br \/>\nSelecting previously deselected package uuid-dev.<br \/>\n(Reading database &#8230; 115845 files and directories currently installed.)<br \/>\nUnpacking uuid-dev (from &#8230;\/uuid-dev_1.2-1.41.3-1_i386.deb) &#8230;<br \/>\nSelecting previously deselected package libapr1-dev.<br \/>\nUnpacking libapr1-dev (from &#8230;\/libapr1-dev_1.2.12-5+lenny1_i386.deb) &#8230;<br \/>\nSelecting previously deselected package libldap2-dev.<br \/>\nUnpacking libldap2-dev (from &#8230;\/libldap2-dev_2.4.11-1_i386.deb) &#8230;<br \/>\nSelecting previously deselected package libexpat1-dev.<br \/>\nUnpacking libexpat1-dev (from &#8230;\/libexpat1-dev_2.0.1-4_i386.deb) &#8230;<br \/>\nSelecting previously deselected package libdb4.6-dev.<br \/>\nUnpacking libdb4.6-dev (from &#8230;\/libdb4.6-dev_4.6.21-11_i386.deb) &#8230;<br \/>\nSelecting previously deselected package libpcrecpp0.<br \/>\nUnpacking libpcrecpp0 (from &#8230;\/libpcrecpp0_7.6-2.1_i386.deb) &#8230;<br \/>\nSelecting previously deselected package libpcre3-dev.<br \/>\nUnpacking libpcre3-dev (from &#8230;\/libpcre3-dev_7.6-2.1_i386.deb) &#8230;<br \/>\nSelecting previously deselected package libsqlite3-dev.<br \/>\nUnpacking libsqlite3-dev (from &#8230;\/libsqlite3-dev_3.5.9-6_i386.deb) &#8230;<br \/>\nSelecting previously deselected package libssl-dev.<br \/>\nUnpacking libssl-dev (from &#8230;\/libssl-dev_0.9.8g-15+lenny3_i386.deb) &#8230;<br \/>\nSelecting previously deselected package libkadm55.<br \/>\nUnpacking libkadm55 (from &#8230;\/libkadm55_1.6.dfsg.4~beta1-5lenny1_i386.deb) &#8230;<br \/>\nSelecting previously deselected package comerr-dev.<br \/>\nUnpacking comerr-dev (from &#8230;\/comerr-dev_2.1-1.41.3-1_i386.deb) &#8230;<br \/>\nSelecting previously deselected package libkrb5-dev.<br \/>\nUnpacking libkrb5-dev (from &#8230;\/libkrb5-dev_1.6.dfsg.4~beta1-5lenny1_i386.deb) &#8230;<br \/>\nSelecting previously deselected package libpq-dev.<br \/>\nUnpacking libpq-dev (from &#8230;\/libpq-dev_8.3.7-0lenny1_i386.deb) &#8230;<br \/>\nSelecting previously deselected package libaprutil1-dev.<br \/>\nUnpacking libaprutil1-dev (from &#8230;\/libaprutil1-dev_1.2.12+dfsg-8+lenny4_i386.deb) &#8230;<br \/>\nProcessing triggers for man-db &#8230;<br \/>\nSetting up uuid-dev (1.2-1.41.3-1) &#8230;<br \/>\nSetting up libapr1-dev (1.2.12-5+lenny1) &#8230;<br \/>\nSetting up libldap2-dev (2.4.11-1) &#8230;<br \/>\nSetting up libexpat1-dev (2.0.1-4) &#8230;<br \/>\nSetting up libdb4.6-dev (4.6.21-11) &#8230;<br \/>\nSetting up libpcrecpp0 (7.6-2.1) &#8230;<br \/>\nSetting up libpcre3-dev (7.6-2.1) &#8230;<br \/>\nSetting up libsqlite3-dev (3.5.9-6) &#8230;<br \/>\nSetting up libssl-dev (0.9.8g-15+lenny3) &#8230;<br \/>\nSetting up libkadm55 (1.6.dfsg.4~beta1-5lenny1) &#8230;<br \/>\nSetting up comerr-dev (2.1-1.41.3-1) &#8230;<br \/>\nSetting up libkrb5-dev (1.6.dfsg.4~beta1-5lenny1) &#8230;<br \/>\nSetting up libpq-dev (8.3.7-0lenny1) &#8230;<br \/>\nSetting up libaprutil1-dev (1.2.12+dfsg-8+lenny4) &#8230;<br \/>\nkomodo:\/home\/jfdesign#<\/p><\/blockquote>\n<p>Now insert this repo cause I don&#8217;t have apache devel on my cdrom :<\/p>\n<blockquote><p>deb http:\/\/ftp.us.debian.org\/debian\/ etch main contrib non-free<\/p><\/blockquote>\n<p>Reload and then installing apache-threaded devel package :<\/p>\n<blockquote><p>komodo:\/home\/jfdesign# apt-get install apache2-threaded-dev<br \/>\nReading package lists&#8230; Done<br \/>\nBuilding dependency tree<br \/>\nReading state information&#8230; Done<br \/>\nThe following packages were automatically installed and are no longer required:<br \/>\ncourier-ssl courier-base courier-authlib-userdb<br \/>\nUse &#8216;apt-get autoremove&#8217; to remove them.<br \/>\nThe following NEW packages will be installed:<br \/>\napache2-threaded-dev<br \/>\n0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.<br \/>\nNeed to get 212kB of archives.<br \/>\nAfter this operation, 807kB of additional disk space will be used.<br \/>\nGet:1 http:\/\/ftp.us.debian.org lenny\/main apache2-threaded-dev 2.2.9-10+lenny4 [212kB]<br \/>\nFetched 212kB in 4s (44.1kB\/s)<br \/>\nSelecting previously deselected package apache2-threaded-dev.<br \/>\n(Reading database &#8230; 117773 files and directories currently installed.)<br \/>\nUnpacking apache2-threaded-dev (from &#8230;\/apache2-threaded-dev_2.2.9-10+lenny4_i386.deb) &#8230;<br \/>\nProcessing triggers for man-db &#8230;<br \/>\nSetting up apache2-threaded-dev (2.2.9-10+lenny4) &#8230;<br \/>\nkomodo:\/home\/jfdesign#<\/p><\/blockquote>\n<p>Now compile the mod_bw with apxs2 :<\/p>\n<blockquote><p>komodo:\/home\/jfdesign\/mod_bw# apxs2 -i -a -c mod_bw.c<br \/>\n\/usr\/share\/apr-1.0\/build\/libtool &#8211;silent &#8211;mode=compile &#8211;tag=disable-static i486-linux-gnu-gcc -prefer-pic -DLINUX=2 -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -D_REENTRANT -I\/usr\/include\/apr-1.0 -I\/usr\/include\/mysql -I\/usr\/include\/openssl -I\/usr\/include\/postgresql -I\/usr\/include\/xmltok -pthread\u00a0\u00a0\u00a0\u00a0 -I\/usr\/include\/apache2\u00a0 -I\/usr\/include\/apr-1.0\u00a0\u00a0 -I\/usr\/include\/apr-1.0 -I\/usr\/include\/postgresql -I\/usr\/include\/mysql\u00a0 -c -o mod_bw.lo mod_bw.c &amp;&amp; touch mod_bw.slo<br \/>\n\/usr\/share\/apr-1.0\/build\/libtool &#8211;silent &#8211;mode=link &#8211;tag=disable-static i486-linux-gnu-gcc -o mod_bw.la\u00a0 -rpath \/usr\/lib\/apache2\/modules -module -avoid-version\u00a0\u00a0\u00a0 mod_bw.lo<br \/>\n\/usr\/share\/apache2\/build\/instdso.sh SH_LIBTOOL=&#8217;\/usr\/share\/apr-1.0\/build\/libtool&#8217; mod_bw.la \/usr\/lib\/apache2\/modules<br \/>\n\/usr\/share\/apr-1.0\/build\/libtool &#8211;mode=install cp mod_bw.la \/usr\/lib\/apache2\/modules\/<br \/>\ncp .libs\/mod_bw.so \/usr\/lib\/apache2\/modules\/mod_bw.so<br \/>\ncp .libs\/mod_bw.lai \/usr\/lib\/apache2\/modules\/mod_bw.la<br \/>\nPATH=&#8221;$PATH:\/sbin&#8221; ldconfig -n \/usr\/lib\/apache2\/modules<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\nLibraries have been installed in:<br \/>\n\/usr\/lib\/apache2\/modules<\/p>\n<p>If you ever happen to want to link against installed libraries<br \/>\nin a given directory, LIBDIR, you must either use libtool, and<br \/>\nspecify the full pathname of the library, or use the `-LLIBDIR&#8217;<br \/>\nflag during linking and do at least one of the following:<br \/>\n&#8211; add LIBDIR to the `LD_LIBRARY_PATH&#8217; environment variable<br \/>\nduring execution<br \/>\n&#8211; add LIBDIR to the `LD_RUN_PATH&#8217; environment variable<br \/>\nduring linking<br \/>\n&#8211; use the `-Wl,&#8211;rpath -Wl,LIBDIR&#8217; linker flag<br \/>\n&#8211; have your system administrator add LIBDIR to `\/etc\/ld.so.conf&#8217;<\/p>\n<p>See any operating system documentation about shared libraries for<br \/>\nmore information, such as the ld(1) and ld.so(8) manual pages.<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\nchmod 644 \/usr\/lib\/apache2\/modules\/mod_bw.so<br \/>\nkomodo:\/home\/jfdesign\/mod_bw#<\/p><\/blockquote>\n<p>Done !, easy isn&#8217;t it ? The results mod_bw.so module now on \/usr\/lib\/apache2\/modules\/mod_bw.so, and it&#8217;s time to add some directive to the apache2.conf or httpd.conf to load the mod_bw module and adjust the parameter. Please make sure this line exist on the apache2.conf and refering to the right path :<\/p>\n<blockquote><p>LoadModule bw_module mod_bw.so<\/p><\/blockquote>\n<p>Within KLIXs, there are nothing to worries, I already compile them and you can install them easily using synaptic or download this and do rpm -Uvh from here.<\/p>\n<p><strong><span style=\"font-family: Arial; font-size: small;\">Second note :<\/span><\/strong><\/p>\n<p><span style=\"font-family: Arial; font-size: small;\">One of my server has already been configure well with ispcp under lenny 5.0.3, the problem is I cannot install apxs due to libaprutil1-dev missing and cannot installed by some dependencies issue with libldap2-dev. I cannot find the corresponding libldap2 that can be use to solve this on lenny, but then I found some workaround to achieve this. I have to step backward by using etch repo to track down the libldap2-dev to satisfied them.<\/span><\/p>\n<p>[root@www jfdesign]# apt-get install libldap2<br \/>\nReading package lists&#8230; Done<br \/>\nBuilding dependency tree<br \/>\nReading state information&#8230; Done<br \/>\nThe following extra packages will be installed:<br \/>\nlibgnutls13 liblzo1 libopencdk8<br \/>\nSuggested packages:<br \/>\ngnutls-bin<br \/>\nThe following NEW packages will be installed:<br \/>\nlibgnutls13 libldap2 liblzo1 libopencdk8<br \/>\n0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.<br \/>\nNeed to get 632kB of archives.<br \/>\nAfter this operation, 1610kB of additional disk space will be used.<br \/>\nDo you want to continue [Y\/n]? y<br \/>\nGet:1 http:\/\/ftp.us.debian.org etch\/main liblzo1 1.08-3 [53.9kB]<br \/>\nGet:2 http:\/\/ftp.us.debian.org etch\/main libopencdk8 0.5.9-2 [102kB]<br \/>\nGet:3 http:\/\/ftp.us.debian.org etch\/main libgnutls13 1.4.4-3+etch4 [315kB]<br \/>\nGet:4 http:\/\/ftp.us.debian.org etch\/main libldap2 2.1.30-13.3 [162kB]<br \/>\nFetched 632kB in 4s (133kB\/s)<br \/>\nSelecting previously deselected package liblzo1.<br \/>\n(Reading database &#8230; 46970 files and directories currently installed.)<br \/>\nUnpacking liblzo1 (from &#8230;\/liblzo1_1.08-3_amd64.deb) &#8230;<br \/>\nSelecting previously deselected package libopencdk8.<br \/>\nUnpacking libopencdk8 (from &#8230;\/libopencdk8_0.5.9-2_amd64.deb) &#8230;<br \/>\nSelecting previously deselected package libgnutls13.<br \/>\nUnpacking libgnutls13 (from &#8230;\/libgnutls13_1.4.4-3+etch4_amd64.deb) &#8230;<br \/>\nSelecting previously deselected package libldap2.<br \/>\nUnpacking libldap2 (from &#8230;\/libldap2_2.1.30-13.3_amd64.deb) &#8230;<br \/>\nReplaced by files in installed package libldap-2.4-2 &#8230;<br \/>\nProcessing triggers for man-db &#8230;<br \/>\nSetting up liblzo1 (1.08-3) &#8230;<br \/>\nSetting up libopencdk8 (0.5.9-2) &#8230;<br \/>\nSetting up libgnutls13 (1.4.4-3+etch4) &#8230;<br \/>\nSetting up libldap2 (2.1.30-13.3) &#8230;<br \/>\n[root@www jfdesign]#<\/p>\n<p><span style=\"font-family: Arial; font-size: small;\">then install the devel package :<\/span><\/p>\n<p>[root@www jfdesign]# apt-get install libldap2-dev<br \/>\nReading package lists&#8230; Done<br \/>\nBuilding dependency tree<br \/>\nReading state information&#8230; Done<br \/>\nThe following NEW packages will be installed:<br \/>\nlibldap2-dev<br \/>\n0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.<br \/>\nNeed to get 251kB of archives.<br \/>\nAfter this operation, 885kB of additional disk space will be used.<br \/>\nGet:1 http:\/\/ftp.us.debian.org etch\/main libldap2-dev 2.1.30-13.3 [251kB]<br \/>\nFetched 251kB in 2s (96.3kB\/s)<br \/>\nSelecting previously deselected package libldap2-dev.<br \/>\n(Reading database &#8230; 47015 files and directories currently installed.)<br \/>\nUnpacking libldap2-dev (from &#8230;\/libldap2-dev_2.1.30-13.3_amd64.deb) &#8230;<br \/>\nProcessing triggers for man-db &#8230;<br \/>\nSetting up libldap2-dev (2.1.30-13.3) &#8230;<br \/>\n[root@www jfdesign]#<\/p>\n<p>[root@www jfdesign]# dpkg -l | grep ldap<br \/>\nii\u00a0 libldap-2.4-2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 2.4.11-1+lenny1\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 OpenLDAP libraries<br \/>\nii\u00a0 libldap2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 2.1.30-13.3\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 OpenLDAP libraries<br \/>\nii\u00a0 libldap2-dev\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 2.1.30-13.3\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 OpenLDAP development libraries<br \/>\nii\u00a0 php5-ldap\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 5.2.6.dfsg.1-1+lenny4\u00a0\u00a0\u00a0 LDAP module for php5<br \/>\nii\u00a0 proftpd-mod-ldap\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1.3.1-17lenny4\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 versatile, virtual-hosting FTP daemon &#8211; LDAP<br \/>\n[root@www jfdesign]#<\/p>\n<p>Now switch back to lenny repo package, and gladly installed libaprutil-dev with big smile :<\/p>\n<p>[root@www jfdesign]# apt-get install libaprutil1-dev<br \/>\nReading package lists&#8230; Done<br \/>\nBuilding dependency tree<br \/>\nReading state information&#8230; Done<br \/>\nThe following extra packages will be installed:<br \/>\ncomerr-dev libapr1-dev libdb4.6-dev libexpat1-dev libkadm55 libkrb5-dev libmysqlclient15-dev libpcre3-dev libpcrecpp0 libpq-dev libsqlite3-dev<br \/>\nlibssl-dev uuid-dev zlib1g-dev<br \/>\nSuggested packages:<br \/>\ndoc-base db4.6-doc krb5-doc postgresql-doc-8.3 sqlite3-doc<br \/>\nThe following NEW packages will be installed:<br \/>\ncomerr-dev libapr1-dev libaprutil1-dev libdb4.6-dev libexpat1-dev libkadm55 libkrb5-dev libmysqlclient15-dev libpcre3-dev libpcrecpp0 libpq-dev<br \/>\nlibsqlite3-dev libssl-dev uuid-dev zlib1g-dev<br \/>\n0 upgraded, 15 newly installed, 0 to remove and 1 not upgraded.<br \/>\nNeed to get 13.4MB of archives.<br \/>\nAfter this operation, 47.7MB of additional disk space will be used.<br \/>\nDo you want to continue [Y\/n]? y<br \/>\nGet:1 http:\/\/ftp.us.debian.org lenny\/main uuid-dev 1.2-1.41.3-1 [59.4kB]<br \/>\nGet:2 http:\/\/ftp.us.debian.org lenny\/main libapr1-dev 1.2.12-5+lenny1 [826kB]<br \/>\nGet:3 http:\/\/ftp.us.debian.org lenny\/main libexpat1-dev 2.0.1-4+lenny3 [224kB]<br \/>\nGet:4 http:\/\/ftp.us.debian.org lenny\/main libdb4.6-dev 4.6.21-11 [730kB]<br \/>\nGet:5 http:\/\/ftp.us.debian.org lenny\/main libpcrecpp0 7.6-2.1 [94.2kB]<br \/>\nGet:6 http:\/\/ftp.us.debian.org lenny\/main libpcre3-dev 7.6-2.1 [260kB]<br \/>\nGet:7 http:\/\/ftp.us.debian.org lenny\/main libsqlite3-dev 3.5.9-6 [333kB]<br \/>\nGet:8 http:\/\/ftp.us.debian.org lenny\/main zlib1g-dev 1:1.2.3.3.dfsg-12 [163kB]<br \/>\nGet:9 http:\/\/ftp.us.debian.org lenny\/main libssl-dev 0.9.8g-15+lenny6 [2242kB]<br \/>\nGet:10 http:\/\/ftp.us.debian.org lenny\/main libkadm55 1.6.dfsg.4~beta1-5lenny2 [170kB]<br \/>\nGet:11 http:\/\/ftp.us.debian.org lenny\/main comerr-dev 2.1-1.41.3-1 [42.1kB]<br \/>\nGet:12 http:\/\/ftp.us.debian.org lenny\/main libkrb5-dev 1.6.dfsg.4~beta1-5lenny2 [92.7kB]<br \/>\nGet:13 http:\/\/ftp.us.debian.org lenny\/main libpq-dev 8.3.9-0lenny1 [453kB]<br \/>\nGet:14 http:\/\/ftp.us.debian.org lenny\/main libmysqlclient15-dev 5.0.51a-24+lenny2+spu1 [7594kB]<br \/>\nGet:15 http:\/\/ftp.us.debian.org lenny\/main libaprutil1-dev 1.2.12+dfsg-8+lenny4 [134kB]<br \/>\nFetched 13.4MB in 1min4s (207kB\/s)<br \/>\nSelecting previously deselected package uuid-dev.<br \/>\n(Reading database &#8230; 47171 files and directories currently installed.)<br \/>\nUnpacking uuid-dev (from &#8230;\/uuid-dev_1.2-1.41.3-1_amd64.deb) &#8230;<br \/>\nSelecting previously deselected package libapr1-dev.<br \/>\nUnpacking libapr1-dev (from &#8230;\/libapr1-dev_1.2.12-5+lenny1_amd64.deb) &#8230;<br \/>\nSelecting previously deselected package libexpat1-dev.<br \/>\nUnpacking libexpat1-dev (from &#8230;\/libexpat1-dev_2.0.1-4+lenny3_amd64.deb) &#8230;<br \/>\nSelecting previously deselected package libdb4.6-dev.<br \/>\nUnpacking libdb4.6-dev (from &#8230;\/libdb4.6-dev_4.6.21-11_amd64.deb) &#8230;<br \/>\nSelecting previously deselected package libpcrecpp0.<br \/>\nUnpacking libpcrecpp0 (from &#8230;\/libpcrecpp0_7.6-2.1_amd64.deb) &#8230;<br \/>\nSelecting previously deselected package libpcre3-dev.<br \/>\nUnpacking libpcre3-dev (from &#8230;\/libpcre3-dev_7.6-2.1_amd64.deb) &#8230;<br \/>\nSelecting previously deselected package libsqlite3-dev.<br \/>\nUnpacking libsqlite3-dev (from &#8230;\/libsqlite3-dev_3.5.9-6_amd64.deb) &#8230;<br \/>\nSelecting previously deselected package zlib1g-dev.<br \/>\nUnpacking zlib1g-dev (from &#8230;\/zlib1g-dev_1%3a1.2.3.3.dfsg-12_amd64.deb) &#8230;<br \/>\nSelecting previously deselected package libssl-dev.<br \/>\nUnpacking libssl-dev (from &#8230;\/libssl-dev_0.9.8g-15+lenny6_amd64.deb) &#8230;<br \/>\nSelecting previously deselected package libkadm55.<br \/>\nUnpacking libkadm55 (from &#8230;\/libkadm55_1.6.dfsg.4~beta1-5lenny2_amd64.deb) &#8230;<br \/>\nSelecting previously deselected package comerr-dev.<br \/>\nUnpacking comerr-dev (from &#8230;\/comerr-dev_2.1-1.41.3-1_amd64.deb) &#8230;<br \/>\nSelecting previously deselected package libkrb5-dev.<br \/>\nUnpacking libkrb5-dev (from &#8230;\/libkrb5-dev_1.6.dfsg.4~beta1-5lenny2_amd64.deb) &#8230;<br \/>\nSelecting previously deselected package libpq-dev.<br \/>\nUnpacking libpq-dev (from &#8230;\/libpq-dev_8.3.9-0lenny1_amd64.deb) &#8230;<br \/>\nSelecting previously deselected package libmysqlclient15-dev.<br \/>\nUnpacking libmysqlclient15-dev (from &#8230;\/libmysqlclient15-dev_5.0.51a-24+lenny2+spu1_amd64.deb) &#8230;<br \/>\nSelecting previously deselected package libaprutil1-dev.<br \/>\nUnpacking libaprutil1-dev (from &#8230;\/libaprutil1-dev_1.2.12+dfsg-8+lenny4_amd64.deb) &#8230;<br \/>\nProcessing triggers for man-db &#8230;<br \/>\nSetting up uuid-dev (1.2-1.41.3-1) &#8230;<br \/>\nSetting up libapr1-dev (1.2.12-5+lenny1) &#8230;<br \/>\nSetting up libexpat1-dev (2.0.1-4+lenny3) &#8230;<br \/>\nSetting up libdb4.6-dev (4.6.21-11) &#8230;<br \/>\nSetting up libpcrecpp0 (7.6-2.1) &#8230;<br \/>\nSetting up libpcre3-dev (7.6-2.1) &#8230;<br \/>\nSetting up libsqlite3-dev (3.5.9-6) &#8230;<br \/>\nSetting up zlib1g-dev (1:1.2.3.3.dfsg-12) &#8230;<br \/>\nSetting up libssl-dev (0.9.8g-15+lenny6) &#8230;<br \/>\nSetting up libkadm55 (1.6.dfsg.4~beta1-5lenny2) &#8230;<br \/>\nSetting up comerr-dev (2.1-1.41.3-1) &#8230;<br \/>\nSetting up libkrb5-dev (1.6.dfsg.4~beta1-5lenny2) &#8230;<br \/>\nSetting up libpq-dev (8.3.9-0lenny1) &#8230;<br \/>\nSetting up libmysqlclient15-dev (5.0.51a-24+lenny2+spu1) &#8230;<br \/>\nSetting up libaprutil1-dev (1.2.12+dfsg-8+lenny4) &#8230;<br \/>\n[root@www jfdesign]#<\/p>\n<p>[root@www jfdesign]# apt-get install apache2-threaded-dev<br \/>\nReading package lists&#8230; Done<br \/>\nBuilding dependency tree<br \/>\nReading state information&#8230; Done<br \/>\nThe following NEW packages will be installed:<br \/>\napache2-threaded-dev<br \/>\n0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.<br \/>\nNeed to get 211kB of archives.<br \/>\nAfter this operation, 807kB of additional disk space will be used.<br \/>\nGet:1 http:\/\/ftp.us.debian.org lenny\/main apache2-threaded-dev 2.2.9-10+lenny6 [211kB]<br \/>\nFetched 211kB in 2s (96.3kB\/s)<br \/>\nSelecting previously deselected package apache2-threaded-dev.<br \/>\n(Reading database &#8230; 49016 files and directories currently installed.)<br \/>\nUnpacking apache2-threaded-dev (from &#8230;\/apache2-threaded-dev_2.2.9-10+lenny6_amd64.deb) &#8230;<br \/>\nProcessing triggers for man-db &#8230;<br \/>\nSetting up apache2-threaded-dev (2.2.9-10+lenny6) &#8230;<br \/>\n[root@www jfdesign]#<\/p>\n<p>Now I have apxs2 on hand to compile the bandwidth limiter module.<\/p>\n<p>Some slight modification needs to be patched to mod.bw.c before compilation if you face this error on restarting apache :<\/p>\n<blockquote><p>[root@www mod_bandwidth]# \/etc\/init.d\/apache2 restart<br \/>\nRestarting web server: apache2We failed to correctly shutdown apache, so we&#8217;re now killing all running apache processes. This is almost certainly suboptimal, so please make sure your system is working as you&#8217;d expect now! (warning).<br \/>\n&#8230; waiting &#8230;.apache2: Syntax error on line 185 of \/etc\/apache2\/apache2.conf: Syntax error on line 1 of \/etc\/apache2\/mods-enabled\/mod_bw.load: Cannot load \/usr\/lib\/apache2\/modules\/mod_bw.so into server: \/usr\/lib\/apache2\/modules\/mod_bw.so: undefined symbol: apr_atomic_cas<br \/>\nfailed!<br \/>\n[root@www mod_bandwidth]#<\/p><\/blockquote>\n<p>And here is the change for mod_bw.c to bypass the compatibility problem :<\/p>\n<blockquote><p>\/* Compatibility for ARP &lt; 1 *\/<br \/>\n#if (APR_MAJOR_VERSION &lt; 1)<br \/>\n#define apr_atomic_inc32 apr_atomic_inc<br \/>\n#define apr_atomic_dec32 apr_atomic_dec<br \/>\n#define apr_atomic_add32 apr_atomic_add<br \/>\n#define apr_atomic_cas32 apr_atomic_cas<br \/>\n#define apr_atomic_set32 apr_atomic_set<br \/>\n#endif<\/p>\n<p>to:<\/p>\n<p>\/* Compatibility for ARP &lt; 1 *\/<br \/>\n\/*<br \/>\n#if (APR_MAJOR_VERSION &lt; 1)<br \/>\n#define apr_atomic_inc32 apr_atomic_inc<br \/>\n#define apr_atomic_dec32 apr_atomic_dec<br \/>\n#define apr_atomic_add32 apr_atomic_add<br \/>\n#define apr_atomic_cas32 apr_atomic_cas<br \/>\n#define apr_atomic_set32 apr_atomic_set<br \/>\n#endif<br \/>\n*\/<\/p><\/blockquote>\n<p>Compile again the mod_bw.c and you should good to go.<\/p>\n<p>Just in case the apxs2 doesn&#8217;t create you the right LoadModule at \/etc\/apache2\/mods_available and the corresponding symlink on \/etc\/apache2\/mods_enabled, then create yourself. Here is the mod_bw.load on mine :<\/p>\n<blockquote><p>LoadModule bw_module \/usr\/lib\/apache2\/modules\/mod_bw.so<\/p><\/blockquote>\n<p>and don&#8217;t forget to create manually the mod_bw.load symlink on \/etc\/apache2\/mods_enabled<\/p>\n<p><strong>Get it to work :<\/strong><\/p>\n<p>Most of us think the installation is the hardest part, no! &#8230; you  wrong, make it work is the most confusing part. I don&#8217;t want to expose my setting due to some security problems, but here is some samples, it;s pretty straight forward, so I don&#8217;t see any difficulties for any webmaster that installed the virtual host hosting by them self. You should know where you put the Virtual Host setting do you ?<\/p>\n<p><strong>Configuration sample for Virtual Host :<\/strong><\/p>\n<blockquote><p>Limit every user to a max of 10Kb\/s on a vhost :<\/p>\n<p>&lt;Virtualhost *&gt;<br \/>\nBandwidthModule On<br \/>\nForceBandWidthModule On<br \/>\nBandwidth all 10240<br \/>\nMinBandwidth all -1<br \/>\nServername www.example.com<br \/>\n&lt;\/Virtualhost&gt;<\/p>\n<p>Limit al internal users (lan) to 1000 kb\/s with a minimum of 50kb\/s , and files greater than 500kb to 50kb\/s.<\/p>\n<p>&lt;Virtualhost *&gt;<br \/>\nBandwidthModule On<br \/>\nForceBandWidthModule On<br \/>\nBandwidth all 1024000<br \/>\nMinBandwidth all 50000<br \/>\nLargeFileLimit * 500 50000<br \/>\nServername www.example.com<br \/>\n&lt;\/Virtualhost&gt;<\/p>\n<p>Limit avi and mpg extensions to 20kb\/s.<\/p>\n<p>&lt;Virtualhost *&gt;<br \/>\nBandwidthModule On<br \/>\nForceBandWidthModule On<br \/>\nLargeFileLimit .avi 1 20000<br \/>\nLargeFileLimit .mpg 1 20000<br \/>\nServername www.example.com<br \/>\n&lt;\/Virtualhost&gt;<\/p>\n<p>Using it the &#8220;right&#8221; way, with output filter by mime type (for text)<br \/>\nto 5kb\/s:<\/p>\n<p>&lt;Virtualhost *&gt;<br \/>\nBandwidthModule On<br \/>\nAddOutputFilterByType MOD_BW text\/html text\/plain<br \/>\nBandwidth all 5000<br \/>\nServername www.example.com<br \/>\n&lt;\/Virtualhost&gt;<\/p><\/blockquote>\n<p>Now I can stop the small nagging sites hogging all the bandwidth of my server !!! I nailed you to the floor &#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Running a webserver with a lot quantity of virtual server is a double-edged sword. The more hosted site, the more income for us, but for every ten legitimate users, there&#8217;s at least one greed user that wants the whole site traffic. This is bad enough under normal circumstances, but it&#8217;s even worse when we&#8217;re on [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,17,9],"tags":[54],"_links":{"self":[{"href":"https:\/\/www.jfdesignnet.com\/index.php?rest_route=\/wp\/v2\/posts\/195"}],"collection":[{"href":"https:\/\/www.jfdesignnet.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jfdesignnet.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jfdesignnet.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jfdesignnet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=195"}],"version-history":[{"count":0,"href":"https:\/\/www.jfdesignnet.com\/index.php?rest_route=\/wp\/v2\/posts\/195\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.jfdesignnet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=195"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jfdesignnet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=195"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jfdesignnet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}