免费注册 查看新帖 |

Chinaunix

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

使用mod_limitipconn模块来限制apache的并发连接数 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-07-31 10:52 |只看该作者 |倒序浏览


解压软件
# tar zxvf httpd-2.0.47.tar.gz
mod_limitipconn是一个限制同一IP连接次数的模块
# tar zxvf mod_limitipconn-0.22.tar.gz
# cd /setup/httpd-2.0.47
给apache打补丁,支持同一ip连接的代理跟踪
# patch -p1
          1.启用线程和进程混合的多道处理模块worker,默认是prefock,即1.3里面的纯进程工作模式,注意,这里如果选择worker的话,那么后面编译PHP的时候是不能选择MM(使用内存来保存会话信息)的支持的!ZendPerformanceSuite只能工作在prefock工作模式!!!
          2.静态编译mod_limitipconn模块到httpd内部(如果你想动态加载安装那就自己去看看README好了,很简单的)
          3.激活同一ip的代理连接跟踪,打的补丁也是针对这个的
# make  
# make install           
#  
# /usr/local/apache/bin/httpd -l
查看编译的模块,注意一下是否有mod_limitipconn的输出。

#################修改apache配置文件######################
# vi /usr/local/apache/conf/httpd.conf
Section 1: Global Environment  部分需要修改如下内容


# worker MPM
# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
StartServers         3
MaxClients         480
MinSpareThreads     50
MaxSpareThreads    200  
ThreadsPerChild     60
MaxRequestsPerChild  0
##################################################################################
#
# ExtendedStatus controls whether Apache will generate "full" status
# information (ExtendedStatus On) or just basic information (ExtendedStatus
# Off) when the "server-status" handler is called. The default is Off.
#
#ExtendedStatus On [把#删除]
ExtendedStatus On
### Section 2: 'Main' server configuration   部分需要修改如下内容
#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If this is not set to valid DNS name for your host, server-generated
# redirections will not work.  See also the UseCanonicalName directive.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
# You will have to access it by its address anyway, and this will make
# redirections work in a sensible way.
#
ServerName 127.0.0.1:80
###################################################################################

#添加mod_limitipconn.c模块及配置

      
         MaxConnPerIP 2    # 每IP只允许2个并发连接
     


### Section 3: Virtual Hosts  需要添加如下部分
        ServerAdmin     
admin@abc.com
        DocumentRoot    /opt/html
        ServerName      down.abc.com
        ErrorLog        /opt/download/logs/patch-error.log   
        CustomLog       /opt/download/logs/patch-access.log common


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

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP