Apache下使用mod_vhost_limit限制虚拟主机并发数
资料来源源自 http://www.allabc.com
相关讨论可访问论坛:http://seecee.dev-c.nl/forumdisplay.php?fid=4
所需模块下载链接如下:
http://www.nowhere-land.org/prog ... st_limit-0.4.tar.gz
该模块的官方网址为: http://www.nowhere-land.org/programs/mod_vhost_limit/
安装步骤如下:
执行命令 apxs -c mod_vhost_limit.c -o /path/to/libexec/mod_vhost_limit.so
需在 httpd.conf 中添加以下配置:
LoadModule vhost_limit_module libexec/mod_vhost_limit.so
AddModule mod_vhost_limit.c
具体配置示例如下:
MaxClients 150
ExtendedStatus On
NameVirtualHost *
ServerName server1
DocumentRoot /some/where/1
MaxVhostClients 100
ServerName server2
DocumentRoot /some/where/2
MaxVhostClients 30
ServerName server3
DocumentRoot /some/where/3
在此配置中,server1 被限制为 100 个并发线程数。 server2 被限制为 30 个并发线程数。 server3 没有被限制。
注:需 mod_status 的 ExtendedStatus On 支持!!
如超出限制的并发数在客户端就会出现503错误:
Service Temporarily Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
--------------------------------------------------------------------------------Apache/1.3.27 Server at server1 Port 80
在 error_log 中将会有类似以下的错误提示:
[Mon Jun 23 15:22:24 2003] [error] client access to server1 deferred, MaxVhostClients 100 exceeded
希望对大家有用!! (出处:http://www.allabc.com)