<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>OurApache &#187; 宽带</title>
	<atom:link href="http://ourapache.com/archives/tag/%e5%ae%bd%e5%b8%a6/feed" rel="self" type="application/rss+xml" />
	<link>http://ourapache.com</link>
	<description>我们致力于一个Apache知识的分享网站</description>
	<lastBuildDate>Tue, 13 Apr 2010 05:18:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>apache限制并发数,IP,带宽设置</title>
		<link>http://ourapache.com/archives/128</link>
		<comments>http://ourapache.com/archives/128#comments</comments>
		<pubDate>Tue, 10 Feb 2009 07:53:17 +0000</pubDate>
		<dc:creator>OurApache</dc:creator>
				<category><![CDATA[Apache高级应用]]></category>
		<category><![CDATA[ip]]></category>
		<category><![CDATA[宽带]]></category>
		<category><![CDATA[并发数]]></category>

		<guid isPermaLink="false">http://www.ourapache.com/?p=128</guid>
		<description><![CDATA[apache限制并发数,IP,带宽设置]]></description>
			<content:encoded><![CDATA[<div id="read_tpc" class="tpc_content">apache限制并发数,<a href="http://ourapache.com/archives/tag/ip" class="st_tag internal_tag" rel="tag" title="标签 ip 下的日志">IP</a>,带宽设置<br />
限制并发数<br />
下载模块： </p>
<p>到官方网址： http://www.nowhere-land.org/programs/mod_vhost_limit/下载模块</p>
<p>http://www.nowhere-land.org/programs/mod_vhost_limit/mod_vhost_limit-0.4.tar.gz</p>
<p>安装：<br />
apxs -c mod_vhost_limit.c -o /path/to/libexec/mod_vhost_limit.so</p>
<p>在 httpd.conf 加入：</p>
<p>LoadModule vhost_limit_module libexec/mod_vhost_limit.so<br />
AddModule mod_vhost_limit.c</p>
<p>配置：</p>
<p>MaxClients 150<br />
ExtendedStatus On</p>
<p>NameVirtualHost *<br />
ServerName server1<br />
DocumentRoot /some/where/1<br />
MaxVhostClients 100<br />
ServerName server2<br />
DocumentRoot /some/where/2<br />
MaxVhostClients 30<br />
ServerName server3<br />
DocumentRoot /some/where/3</p>
<p>其中： server1 被限制为 100 个并发线程数。 server2 被限制为 30 个并发线程数。 server3 没有被限制。</p>
<p>注：需 mod_status 的 ExtendedStatus On 支持！！</p>
<p>如超出限制的并发数在客户端就会出现503错误</p>
<p>———————————————————————————————-</p>
<p>限制IP连接数</p>
<p>到这里下载模块 http://dominia.org/djao/limit/mod_limitipconn-0.04.tar.gz</p>
<p>安装:<br />
tar zxvf mod_limitipconn-0.04.tar.gz<br />
cd mod_limitipconn-0.04<br />
make APXS=/usr/local/apache/bin/apxs ß—–这里要按你自己的路径设置<br />
make install APXS=/usr/local/apache/bin/apxs ß—–这里要按你自己的路径设置</p>
<p>编辑httpd.conf<br />
添加<br />
全局变量:<br />
&lt; IfModule mod_limitipconn.c &gt;<br />
&lt; Location / &gt; # 所有虚拟主机的/目录<br />
MaxConnPerIP 3 # 每IP只允许3个并发连接<br />
NoIPLimit image/* # 对图片不做IP限制<br />
&lt; /Location &gt;</p>
<p>&lt; Location /mp3 &gt; # 所有主机的/mp3目录<br />
MaxConnPerIP 1 # 每IP只允许一个连接请求<br />
OnlyIPLimit audio/mpeg video # 该限制只对视频和音频格式的文件<br />
&lt; /Location &gt;<br />
&lt; /IfModule &gt;</p>
<p>或者虚拟主机的:<br />
&lt; VirtualHost xx.xxx.xx.xx &gt; ##ip 地址<br />
ServerAdmin easy@phpv.net<br />
DocumentRoot /home/easy<br />
ServerName www.phpv.net<br />
&lt; IfModule mod_limitipconn.c &gt;<br />
&lt; Location / &gt;<br />
MaxConnPerIP 5<br />
NoIPLimit image/*<br />
&lt; /Location &gt;<br />
&lt; Location /mp3 &gt; # 所有主机的/mp3目录<br />
MaxConnPerIP 2 # 每IP只允许一个连接请求<br />
OnlyIPLimit audio/mpeg video # 该限制只对视频和音频格式的文件<br />
&lt; /Location &gt;<br />
&lt; /IfModule &gt;<br />
&lt; /VirtualHost &gt;</p>
<p>———————————————————————————————-</p>
<p>限制带宽：</p>
<p>下载模块 ftp://ftp.cohprog.com/pub/apache/module/1.3.0/mod_bandwidth.c<br />
安装:<br />
/usr/local/apache/bin/apxs -c ./mod_bandwidth.c -o /usr/local/apache/libexec/mod_bandwidth.so</p>
<p>&lt;——-以上/usr/local/apache请设置为你的路径</p>
<p>编辑httpd.conf<br />
添加：<br />
LoadModule bandwidth_module libexec/mod_bandwidth.so<br />
AddModule mod_bandwidth.c</p>
<p>重启你的apache</p>
<p>相关文档：</p>
<p>Global configuration directives :</p>
<p>BandWidthDataDir<br />
Syntax : BandWidthDataDir<br />
Default : “/tmp/apachebw”<br />
Context : server config<br />
Sets the name of the root directory used by mod_bandwidth to store its internal temporary information. Don’t forget to create the needed directories : /master and /link</p>
<p>BandWidthModule<br />
Syntax : BandWidthModule</p></div>
<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li>2009年02月7号 -- <a href="http://ourapache.com/archives/92" title="在Apache下限制每个虚拟主机的并发数">在Apache下限制每个虚拟主机的并发数</a></li><li>2008年12月27号 -- <a href="http://ourapache.com/archives/9" title="apache禁止使用IP访问的实现方法">apache禁止使用IP访问的实现方法</a></li></ul>
	标签：<a href="http://ourapache.com/archives/category/advanced" title="Apache高级应用" rel="tag">Apache高级应用</a>, <a href="http://ourapache.com/archives/tag/ip" title="ip" rel="tag">ip</a>, <a href="http://ourapache.com/archives/tag/%e5%ae%bd%e5%b8%a6" title="宽带" rel="tag">宽带</a>, <a href="http://ourapache.com/archives/tag/%e5%b9%b6%e5%8f%91%e6%95%b0" title="并发数" rel="tag">并发数</a><br />
]]></content:encoded>
			<wfw:commentRss>http://ourapache.com/archives/128/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

