免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 970 | 回复: 0
打印 上一主题 下一主题

apache限制并发数 IP 带宽设置教程 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-01-09 09:06 |只看该作者 |倒序浏览
限制并发数
下载模块:
到官方网址:
http://www.nowhere-land.org/programs/mod_vhost_limit/
下载模块
http://www.nowhere-land.org/programs/mod_vhost_limit/mod_vhost_limit-0.4.tar.gz
安装:
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错误
----------------------------------------------------------------------------------------------
限制IP连接数
到这里下载模块
http://dominia.org/djao/limit/mod_limitipconn-0.04.tar.gz
安装:
tar zxvf mod_limitipconn-0.04.tar.gz
cd mod_limitipconn-0.04
make APXS=/usr/local/apache/bin/apxs ß-----这里要按你自己的路径设置
make install APXS=/usr/local/apache/bin/apxs ß-----这里要按你自己的路径设置
编辑httpd.conf
添加
全局变量:
  
          # 所有虚拟主机的/目录
          MaxConnPerIP 3     # 每IP只允许3个并发连接
           NoIPLimit image/*   # 对图片不做IP限制
     
     # 所有主机的/mp3目录
    MaxConnPerIP 1         # 每IP只允许一个连接请求   
    OnlyIPLimit audio/mpeg video     # 该限制只对视频和音频格式的文件
     
  
或者虚拟主机的:
##ip 地址
    ServerAdmin
easy@phpv.net
    DocumentRoot /home/easy
    ServerName www.phpv.net
  
           
      MaxConnPerIP 5         
          NoIPLimit image/*      
       
           # 所有主机的/mp3目录
      MaxConnPerIP 2         # 每IP只允许一个连接请求   
      OnlyIPLimit audio/mpeg video # 该限制只对视频和音频格式的文件
      
  
  
----------------------------------------------------------------------------------------------
限制带宽:
下载模块
ftp://ftp.cohprog.com/pub/apache/module/1.3.0/mod_bandwidth.c
安装:
/usr/local/apache/bin/apxs -c ./mod_bandwidth.c -o /usr/local/apache/libexec/mod_bandwidth.so   
请设置为你的路径
编辑httpd.conf
添加:
LoadModule bandwidth_module libexec/mod_bandwidth.so
AddModule mod_bandwidth.c
重启你的apache。


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/73175/showart_1784192.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP