2.解压:tar -zxvf mod_qos-10.26.tar.gz
3.安装
cd mod_qos-10.26
cd apache2/
/usr/local/apache2/bin/apxs -i -c mod_qos.c
输出:
/usr/local/apache2/build/libtool --silent --mode=compile gcc -std=gnu99 -prefer-pic -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -g -O2 -pthread -I/usr/local/apache2/include -I/usr/local/apache2/include -I/usr/local/apache2/include -c -o mod_qos.lo mod_qos.c && touch mod_qos.slo
/usr/local/apache2/build/libtool --silent --mode=link gcc -std=gnu99 -o mod_qos.la -rpath /usr/local/apache2/modules -module -avoid-version mod_qos.lo
/usr/local/apache2/build/instdso.sh SH_LIBTOOL='/usr/local/apache2/build/libtool' mod_qos.la /usr/local/apache2/modules
/usr/local/apache2/build/libtool --mode=install install mod_qos.la /usr/local/apache2/modules/
libtool: install: install .libs/mod_qos.so /usr/local/apache2/modules/mod_qos.so
libtool: install: install .libs/mod_qos.lai /usr/local/apache2/modules/mod_qos.la
libtool: install: install .libs/mod_qos.a /usr/local/apache2/modules/mod_qos.a
libtool: install: chmod 644 /usr/local/apache2/modules/mod_qos.a
libtool: install: ranlib /usr/local/apache2/modules/mod_qos.a
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/sbin" ldconfig -n /usr/local/apache2/modules
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/apache2/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
chmod 755 /usr/local/apache2/modules/mod_qos.so
/usr/local/apache2/build/libtool --silent --mode=link gcc -std=gnu99 -o mod_qos.la -rpath /usr/local/apache2/modules -module -avoid-version mod_qos.lo
/usr/local/apache2/build/instdso.sh SH_LIBTOOL='/usr/local/apache2/build/libtool' mod_qos.la /usr/local/apache2/modules
/usr/local/apache2/build/libtool --mode=install install mod_qos.la /usr/local/apache2/modules/
libtool: install: install .libs/mod_qos.so /usr/local/apache2/modules/mod_qos.so
libtool: install: install .libs/mod_qos.lai /usr/local/apache2/modules/mod_qos.la
libtool: install: install .libs/mod_qos.a /usr/local/apache2/modules/mod_qos.a
libtool: install: chmod 644 /usr/local/apache2/modules/mod_qos.a
libtool: install: ranlib /usr/local/apache2/modules/mod_qos.a
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/sbin" ldconfig -n /usr/local/apache2/modules
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/apache2/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
chmod 755 /usr/local/apache2/modules/mod_qos.so
4.配置
配置Apache httpd.conf
加入一行:LoadModule qos_module modules/mod_qos.so
编辑配置 qos.conf
加入如下内容:
# maximum number of active TCP connections is limited to 896 (limited # by the available memory, adjust the settings according to the used # hardware): MaxClients 896 # idle timeout: Timeout 20 # keep alive (for up to 85% of all connections): KeepAlive on MaxKeepAliveRequests 60 KeepAliveTimeout 3 QS_SrvMaxConnClose 85% # name of the HTTP response header which marks preferred clients (this # may be used to let the application decide which clients are "good" and # have higher privileges, e.g. authenticated users. you may also use # the QS_VipUser directive when using an Apache authentication module such # as mod_auth_basic or mod_auth_oid): QS_VipIPHeaderName mod-qos-login # enables the known client prefer mode (server allows new TCP connections # from known/good clients only when is has more than 716 open TCP connections): QS_ClientPrefer 80 # minimum request/response speed (deny slow clients blocking the server, # e.g. defending slowloris) if the server has 500 or more open connections: QS_SrvMinDataRate 120 1500 500 # and limit request line, header and body: LimitRequestLine 7168 LimitRequestFields 30 QS_LimitRequestBody 102400 # don't allow more than 30 TCP connections per client source address if # 500 connections are open to the server: QS_SrvMaxConnPerIP 30 500 # block clients violating some basic rules frequently (don't allows more than 20 # violations within 5 minutes): QS_ClientEventBlockCount 20 300 QS_SetEnvIfStatus 400 QS_Block QS_SetEnvIfStatus 401 QS_Block QS_SetEnvIfStatus 403 QS_Block QS_SetEnvIfStatus 404 QS_Block QS_SetEnvIfStatus 405 QS_Block QS_SetEnvIfStatus 406 QS_Block QS_SetEnvIfStatus 408 QS_Block QS_SetEnvIfStatus 411 QS_Block QS_SetEnvIfStatus 413 QS_Block QS_SetEnvIfStatus 414 QS_Block QS_SetEnvIfStatus 417 QS_Block QS_SetEnvIfStatus 500 QS_Block QS_SetEnvIfStatus 503 QS_Block QS_SetEnvIfStatus 505 QS_Block QS_SetEnvIfStatus QS_SrvMinDataRate QS_Block QS_SetEnvIfStatus NullConnection QS_Block
在Apache httpd.conf中加入一行:Include conf/qos.conf导入qos配置
重启Apache,报错:Invalid command 'QS_SrvMinDataRate', perhaps misspelled or defined by a module not included in the server configuration
暂时解决方式:将此命令注释。
另外,有两个警告:
AH00513: WARNING: MaxRequestWorkers of 896 is not an integer multiple of
ThreadsPerChild of 25, decreasing to nearest multiple 875,
for a maximum of 35 servers.
AH00515: WARNING: MaxRequestWorkers of 875 would require 35 servers and
would exceed ServerLimit of 16, decreasing to 400.
To increase, please see the ServerLimit directive
解决方式:将MaxClients 改为400.
重启Apache。 其中QS_SrvMinDataRate 命令会由于兼容性与Apache 2.4的有冲突,注释掉该命令,及与其相关的命令。 Apache的错误日志中会有提示,qos只适用于Apache 2.2版本。经过测试其他不冲突的命令也可以正常运行。![]()