<?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>haohtml&#039;s blog &#187; apache</title>
	<atom:link href="http://blog.haohtml.com/index.php/tag/apache/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.haohtml.com</link>
	<description>haohtml&#039;s life and works blog</description>
	<lastBuildDate>Sat, 31 Jul 2010 10:45:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>张宴《实战Nginx：取代Apache的高性能Web服务器》pdf电子书下载</title>
		<link>http://blog.haohtml.com/index.php/archives/4722</link>
		<comments>http://blog.haohtml.com/index.php/archives/4722#comments</comments>
		<pubDate>Tue, 20 Jul 2010 11:34:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[服务器类]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://blog.haohtml.com/?p=4722</guid>
		<description><![CDATA[张宴《实战Nginx：取代Apache的高性能Web服务器》pdf电子书下载 目录介绍： 第1部分 基础篇 第1章 Nginx简介 1.1 常用的Web服务器简介 1.2 Nginx简介 1.3 选择Nginx的理由 1.4 Nginx与Apache、Lighttpd的综合对比 第2章 Nginx服务器的安装与配置 2.1 安装Nginx服务器所需要的系统资源 2.2 Nginx的下载 2.3 Nginx的安装 2.4 Nginx的启动、停止、平滑重启 2.5 Nginx的平滑重启 2.6 Nginx的信号控制 2.7 Nginx的平滑升级第2部分 进 阶 篇 第3章 Nginx的基本配置与优化 3.1 Nginx的完整配置示例 3.2 Nginx的虚拟主机配置 3.3 Nginx的日志文件配置与切割 3.4 Nginx的压缩输出配置 .3.5 Nginx的自动列目录配置 3.6 Nginx的浏览器本地缓存设置 第4章 Nginx与PHP（FastCGI）的安装、配置与优化 4.1 获取相关开源程序 4.2 安装PHP 5.2.10（FastCGI模式） 4.3 [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.s135.com/" target="_blank">张宴</a>《<a title="PDF下载" href="http://www.sbear.cn/download/nginx_pdf.tar.gz" target="_blank">实战Nginx：取代Apache的高性能Web服务器</a>》pdf电子书下载</p>
<p>目录介绍：</p>
<p>第1部分 基础篇<br />
第1章 Nginx简介<br />
1.1 常用的Web服务器简介<br />
1.2 Nginx简介<br />
1.3 选择Nginx的理由<br />
1.4 Nginx与Apache、Lighttpd的综合对比<br />
第2章 Nginx服务器的安装与配置<br />
2.1 安装Nginx服务器所需要的系统资源<br />
2.2 Nginx的下载<br />
2.3 Nginx的安装<br />
2.4 Nginx的启动、停止、平滑重启<br />
2.5 Nginx的平滑重启<br />
2.6 Nginx的信号控制<br />
2.7 Nginx的平滑升级<span id="more-4722"></span>第2部分 进 阶 篇<br />
第3章 Nginx的基本配置与优化<br />
3.1 Nginx的完整配置示例<br />
3.2 Nginx的虚拟主机配置<br />
3.3 Nginx的日志文件配置与切割<br />
3.4 Nginx的压缩输出配置<br />
.3.5 Nginx的自动列目录配置<br />
3.6 Nginx的浏览器本地缓存设置<br />
第4章 Nginx与PHP（FastCGI）的安装、配置与优化<br />
4.1 获取相关开源程序<br />
4.2 安装PHP 5.2.10（FastCGI模式）<br />
4.3 安装Nginx 0.8.15<br />
4.4 配置开机自动启动Nginx + PHP<br />
4.5 优化Linux内核参数<br />
4.6 在不停止Nginx服务的情况下平滑变更Nginx配置<br />
4.7 编写每天定时切割Nginx日志的脚本<br />
第5章 Nginx与JSP、ASP.NET、Perl的安装与配置<br />
5.1 Nginx与JSP（Tomcat）在Linux上的安装、配置<br />
5.2 Nginx与ASP.NET（Mono+FastCGI）在Linux上的安装、配置<br />
5.3 Nginx与Perl（FastCGI）在Linux上的安装、配置<br />
第6章 Nginx HTTP负载均衡和反向代理的配置与优化<br />
6.1 什么是负载均衡和反向代理<br />
6.2 常见的Web负载均衡方法<br />
6.3 Nginx负载均衡与反向代理的配置实例<br />
6.4 Nginx负载均衡的HTTP Upstream 模块<br />
6.5 Nginx负载均衡服务器的双机高可用<br />
第7章 Nginx的Rewrite规则编写实例<br />
7.1 什么是Nginx的Rewrite规则<br />
7.2 Nginx Rewrite规则相关指令<br />
7.3 PCRE正则表达式语法<br />
7.4 Nginx的Rewrite规则编写实例<br />
7.5 Nginx与Apache的Rewrite规则实例对比<br />
第8章 Nginx模块开发<br />
8.1 Nginx模块概述<br />
8.2 Nginx模块编写实践<br />
第9章 Nginx的Web缓存服务与新浪网的开源NCACHE模块<br />
9.1 什么是Web缓存？<br />
9.2 Nginx的Web缓存服务<br />
9.3 新浪网开源软件项目——基于Nginx的NCache网页缓存系统<br />
第3部分 实战篇<br />
第10章 Nginx在国内知名网站中的应用案例<br />
10.1 Nginx反向代理与负载均衡类网站应用案例<br />
10.2 Nginx+PHP类网站应用案例<br />
第11章 Nginx的非典型应用实例<br />
11.1 用HTTPS（SSL）构建一个安全的Nginx Web服务器<br />
11.2 采用Nginx搭建FLV视频服务器<br />
11.3 Nginx+PHP+MySQL在小内存VPS服务器上的优化<br />
11.4 采用Nginx搭建正向代理服务器<br />
第4部分 模块篇<br />
第12章 Nginx的核心模块<br />
12.1 主模块指令<br />
12.2 主模块变量<br />
12.3 事件模块指令<br />
第13章 Nginx的标准HTTP模块<br />
13.1 HTTP的核心模块<br />
13.2 HTTP Upstream模块<br />
13.3 Http Access 模块<br />
13.4 HTTP Auth Basic 模块<br />
13.5 Http Autoindex 模块<br />
13.6 Http Browser 模块<br />
13.7 Http Charset 模块<br />
13.8 Http Empty Gif模块<br />
13.9 Http Fcgi 模块<br />
13.10 geo 模块<br />
13.11 Gzip 模块<br />
13.12 Http Headers模块<br />
13.13 Http Index模块<br />
13.14 HTTP Referer模块<br />
13.15 Http Limit Zone模块<br />
13.16 Http Limit Req模块<br />
13.17 Http Log模块<br />
13.18 Http Map模块<br />
13.19 Http Memcached模块<br />
13.20 Http Proxy模块<br />
第14章 Nginx的其他HTTP模块<br />
14.1 Http Addition模块<br />
14.2 Embedded Perl模块<br />
14.3 Flv Stream模块<br />
14.3 flv 指令<br />
14.4 Http Gzip Static模块<br />
14.5 Http Random Index模块<br />
14.6 Http Geo IP模块<br />
14.7 Http RealIp模块<br />
14.8 Http SSL模块<br />
14.9 Http Stub Status模块<br />
14.10 Http Sub模块<br />
14.11 Http Dav模块<br />
14.12 Google Perftools模块<br />
14.13 Http XSLT模块<br />
14.14 Http Secure Link模块<br />
14.15 Http Image Filter模块<br />
第15章 Nginx的邮件模块<br />
15.1 Nginx邮件核心模块<br />
15.2 Nginx邮件认证模块<br />
15.3 Nginx邮件代理模块<br />
15.4 Nginx邮件SSL模块<br />
15.5 Nginx邮件模块配置实例<br />
索引<br />
参考资料</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.haohtml.com/index.php/archives/4722/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[教程]apache中的AB压力测试工具详解-转载</title>
		<link>http://blog.haohtml.com/index.php/archives/4673</link>
		<comments>http://blog.haohtml.com/index.php/archives/4673#comments</comments>
		<pubDate>Thu, 15 Jul 2010 03:20:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[服务器类]]></category>
		<category><![CDATA[ab]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[压力测试]]></category>

		<guid isPermaLink="false">http://blog.haohtml.com/?p=4673</guid>
		<description><![CDATA[最近对聚聚呀新架构作了一个测试,200个请求,20个并发.这样的测试强度,CPU占了70-80%,w3p占用了70多M内存,本想多测几次,看看它的内存会不会涨上去,没有测试机器没办法,开发机要干活.我估计CPU就有问题了,性能有好些个地方还需要优化. 顺便把测试的工具用法作个记号 基本用法: ab -n 全部请求数 -c 并发数 测试url 例:ab -n 1000 -c 50 http://www.newdev.gztest.com/ Server Software:         Microsoft-IIS/7.0 Server Hostname:        www.newdev.gztest.com Server Port:            80 Document Path: Document Length:        82522 bytes  #请求文档大小 Concurrency Level:      50           [...]]]></description>
			<content:encoded><![CDATA[<p>最近对聚聚呀新架构作了一个测试,200个请求,20个并发.这样的测试强度,CPU占了70-80%,w3p占用了70多M内存,本想多测几次,看看它的内存会不会涨上去,没有测试机器没办法,开发机要干活.我估计CPU就有问题了,性能有好些个地方还需要优化.<br />
顺便把测试的工具用法作个记号</p>
<p>基本用法:<br />
ab  -n 全部请求数 -c  并发数  测试url<br />
例:ab -n  1000 -c 50 <a href="http://www.abc.com/a.php" target="_blank"><span style="color: #354845;">http://www.newdev.gztest.com</span></a>/<br />
Server  Software:         Microsoft-IIS/7.0<br />
Server  Hostname:        <span><a href="http://www.abc.com/a.php" target="_blank"><span style="color: #354845;">www.newdev.gztest.com</span></a></span><br />
Server  Port:            80<br />
Document Path:<br />
Document Length:        82522  bytes  #请求文档大小<br />
<span id="more-4673"></span><br />
Concurrency  Level:      50           #并发数<br />
Time taken for tests:   92.76140 seconds #全部请求完成耗时<br />
Complete  requests:      10000          #全部请求数<br />
Failed  requests:        1974           #失败的请求<br />
(Connect: 0, Length: 1974, Exceptions: 0)<br />
Write errors:           0<br />
Total  transferred:      827019400 bytes   #总传输大小<br />
HTML  transferred:       825219400 bytes //整个场景中的HTML内容传输量<br />
Requests  per second:    108.61 [#/sec] (mean)   #每秒请求数(平均)//大家最关心的指标之一，相当于 LR 中的<strong>每秒事务数</strong>，后面括号中的 mean 表示这是一个平均值<br />
Time  per request:       460.381 [ms] (mean)   #每次并发请求时间(所有并发)  //大家最关心的指标之二，相当于 LR  中的<strong>平均事务响应时间</strong>，后面括号中的 mean 表示这是一个平均值<br />
Time  per request:       9.208 [ms] (mean, across all concurrent requests)    #每一请求时间(并发平均)   //每个请求实际运行时间的平均值<br />
Transfer  rate:          8771.39 [Kbytes/sec] received    #传输速率//平均每秒网络上的流量，可以帮助排除是否存在网络流量过大导致响应时间延长的问题<br />
Percentage  of the requests served within a certain time (ms)<br />
50%   2680<br />
66%    2806<br />
75%   2889<br />
80%   2996<br />
90%  11064<br />
95%  20161<br />
98%   21092<br />
99%  21417<br />
100%  21483 (longest request)<br />
//整个场景中所有请求的响应情况。在场景中每个请求都有一个响应时间，其中50％的用户响应时间小于2680毫秒，60％ 的用户响应时间小于2806毫秒，最大的响应时间小于21417毫秒</p>
<div>由于对于并发请求，cpu实际上并不是同时处理的，而是按照每个请求获得的时间片逐个轮转处理的，所以基本上第一个Time  per request时间约等于第二个Time per request时间乘以并发请求数。</div>
<p>Connection  Times (ms)    #连接时间<br />
min  mean[+/-sd] median   max<br />
Connect(#连接):         0    0   2.1      0      46<br />
Processing(#处理):     31  458  94.7    438    1078<br />
Waiting(#等待):        15  437  87.5    422     938<br />
Total:         31  458  94.7    438     1078</p>
<p>其它参数:</p>
<p>-n  requests     全部请求数<br />
-c  concurrency  并发数<br />
-t  timelimit    最传等待回应时间<br />
-p  postfile     POST数据文件<br />
-T  content-type POST Content-type<br />
-v verbosity    How much troubleshooting info  to print<br />
-w              Print out results in HTML tables<br />
-i               Use HEAD instead of GET<br />
-x attributes   String to insert as table  attributes<br />
-y attributes   String to insert as tr attributes<br />
-z attributes    String to insert as td or th attributes<br />
-C attribute    加入cookie,  eg. &#8216;Apache=1234. (repeatable)<br />
-H attribute    加入http头, eg.  &#8216;Accept-Encoding: gzip&#8217;<br />
Inserted after all normal header  lines. (repeatable)<br />
-A attribute    http验证,分隔传递用户名及密码<br />
-P  attribute    Add Basic Proxy Authentication, the attributes<br />
are a colon separated username and password.<br />
-X proxy:port   代理服务器<br />
-V               查看ab版本<br />
-k               Use HTTP KeepAlive feature<br />
-d              Do not show  percentiles served table.<br />
-S              Do not show confidence estimators  and warnings.<br />
-g filename     Output collected data to gnuplot format  file.<br />
-e filename     Output CSV file with percentages served<br />
-h               Display usage information (this message)</p>
<p>来源：<a href="http://www.cnblogs.com/Leung/archive/2009/09/17/1568396.html" target="_blank">http://www.cnblogs.com/Leung/archive/2009/09/17/1568396.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.haohtml.com/index.php/archives/4673/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache最大连接数性能测试</title>
		<link>http://blog.haohtml.com/index.php/archives/4667</link>
		<comments>http://blog.haohtml.com/index.php/archives/4667#comments</comments>
		<pubDate>Thu, 15 Jul 2010 02:48:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[服务器类]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[压力测试]]></category>

		<guid isPermaLink="false">http://blog.haohtml.com/?p=4667</guid>
		<description><![CDATA[Apache最大连接数性能测试。 这天工作没什么事情，翻开看资料，再次学习一下apache的性能优化，以下就说说我的设置及测试。 先说一下我的测试机硬件及软件配置环境： 硬件：一台比较古老的机器，cpu: P42.0 ,内存256，其他的就不多说了。 软件：linux as 4 , apache2.0.59。 先说一下这次安装及配置就是测试apache的性能，如果你打算看其他方面的，那就不要看了，因为偶也没有写，嘿嘿嘿…… ./configure &#8211;prefix=/usr/local/apache2 &#8211;with-mpm=worker &#8211;enable-so 说明： MPM={beos&#124;worker&#124;prefork&#124;mpmt_os2&#124; perchild&#124;leader&#124;threadpool} 我这里mpm使用的是worker,以下说明一下mpm个参数； MPM的引入是Apache 2.x最重要的变化，影响apache2.x 性能的最核心特性， MPM（Multi -Processing Modules，多道处理模块），运行在一种多进程与多线程相混合的模式下，增强部分配置的可扩充性能。相比于Apache 1.3， 2.x版本本做了大量的优化来提升处理能力和可伸缩性，并且大多数改进在默认状态下即可生效。但是在编译和运行时刻，2.x也有许多可以显著提高性能的选择。 Beos、mpmt_os2分别是BeOS和OS/2上缺省的MPM。 perchild主要设计目的是以不同的用户和组的身份来运行不同的子进程。这在运行多个需要CGI的虚拟主机时特别有用，会比1.3版本中的SuExec 机制做得更好。 leader和threadpool都是基于worker的变体。 prefork就是Unix平台上缺省的MPM。它所采用的预派生子进程方式也是 Apache 1.3中采用的模式。prefork本身并没有使用到线程，2.x版本使用它是为了与1.3版本保持兼容性；另一方面，prefork用单独的子进程来处理不同的请求，进程之间是彼此独立的，这也使其成为最稳定的MPM之一。若使用prefork，在make编译和make install安装后，使用“httpd -l”来确定当前使用的MPM，应该会看到prefork.c查看缺省生成的httpd.conf配置文件，里面包含如下配置段： &#60;IfModule prefork.c&#62; StartServers 5 MinSpareServers 5 MaxSpareServers 10 MaxClients 150 MaxRequestsPerChild 0 &#60;/IfModule&#62; worker的工作原理是，由主控制进程生成“StartServers”个子进程，每个子进程中包含固定的ThreadsPerChild 线程数，各个线程独立地处理请求。同样，为了不在请求到来时再临时生成线程，MinSpareThreads和MaxSpareThreads设置了最少和最多的空闲线程数；而MaxClients设置了所有子进程中的线程总数。如果现有子进程中的线程总数不能满足负载，控制进程将派生新的子进程。 worker的工作原理是，由主控制进程生成“StartServers”个子进程，每个子进程中包含固定的ThreadsPerChild 线程数，各个线程独立地处理请求。同样，为了不在请求到来时再临时生成线程，MinSpareThreads和MaxSpareThreads设置了最少和最多的空闲线程数；而MaxClients设置了所有子进程中的线程总数。如果现有子进程中的线程总数不能满足负载，控制进程将派生新的子进程。 MinSpareThreads和MaxSpareThreads的最大缺省值分别是75和250。这两个参数对Apache的性能影响并不大，可以按照实际情况相应调节。 [...]]]></description>
			<content:encoded><![CDATA[<p>Apache最大连接数性能测试。</p>
<p>这天工作没什么事情，翻开看资料，再次学习一下apache的性能优化，以下就说说我的设置及测试。</p>
<p>先说一下我的测试机硬件及软件配置环境：</p>
<p>硬件：一台比较古老的机器，cpu: P42.0 ,内存256，其他的就不多说了。</p>
<p>软件：linux as 4 , apache2.0.59。</p>
<p>先说一下这次安装及配置就是测试apache的性能，如果你打算看其他方面的，那就不要看了，因为偶也没有写，嘿嘿嘿……</p>
<p>./configure &#8211;prefix=/usr/local/apache2 &#8211;with-mpm=worker &#8211;enable-so</p>
<p>说明：</p>
<p>MPM={beos|worker|prefork|mpmt_os2| perchild|leader|threadpool}</p>
<p>我这里mpm使用的是worker,以下说明一下mpm个参数；</p>
<p>MPM的引入是Apache 2.x最重要的变化，影响apache2.x 性能的最核心特性，</p>
<p>MPM（Multi -Processing Modules，多道处理模块），运行在一种多进程与多线程相混合的模式下，增强部分配置的可扩充性能。相比于Apache 1.3， 2.x版本本做了大量的优化来提升处理能力和可伸缩性，并且大多数改进在默认状态下即可生效。但是在编译和运行时刻，2.x也有许多可以显著提高性能的选择。<span id="more-4667"></span></p>
<p>Beos、mpmt_os2分别是BeOS和OS/2上缺省的MPM。</p>
<p>perchild主要设计目的是以不同的用户和组的身份来运行不同的子进程。这在运行多个需要CGI的虚拟主机时特别有用，会比1.3版本中的SuExec 机制做得更好。</p>
<p>leader和threadpool都是基于worker的变体。</p>
<p>prefork就是Unix平台上缺省的MPM。它所采用的预派生子进程方式也是 Apache 1.3中采用的模式。prefork本身并没有使用到线程，2.x版本使用它是为了与1.3版本保持兼容性；另一方面，prefork用单独的子进程来处理不同的请求，进程之间是彼此独立的，这也使其成为最稳定的MPM之一。若使用prefork，在make编译和make install安装后，使用“httpd -l”来确定当前使用的MPM，应该会看到prefork.c查看缺省生成的httpd.conf配置文件，里面包含如下配置段：</p>
<blockquote><p><span style="font-size: small;"><span style="font-size: small;"><span style="line-height: normal; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">&lt;IfModule prefork.c&gt;<br />
StartServers 5<br />
MinSpareServers 5<br />
MaxSpareServers 10<br />
MaxClients 150<br />
MaxRequestsPerChild 0<br />
&lt;/IfModule&gt;</span></span></span></p></blockquote>
<p>worker的工作原理是，由主控制进程生成“StartServers”个子进程，每个子进程中包含固定的ThreadsPerChild 线程数，各个线程独立地处理请求。同样，为了不在请求到来时再临时生成线程，MinSpareThreads和MaxSpareThreads设置了最少和最多的空闲线程数；而MaxClients设置了所有子进程中的线程总数。如果现有子进程中的线程总数不能满足负载，控制进程将派生新的子进程。</p>
<p>worker的工作原理是，由主控制进程生成“StartServers”个子进程，每个子进程中包含固定的ThreadsPerChild 线程数，各个线程独立地处理请求。同样，为了不在请求到来时再临时生成线程，MinSpareThreads和MaxSpareThreads设置了最少和最多的空闲线程数；而MaxClients设置了所有子进程中的线程总数。如果现有子进程中的线程总数不能满足负载，控制进程将派生新的子进程。</p>
<p>MinSpareThreads和MaxSpareThreads的最大缺省值分别是75和250。这两个参数对Apache的性能影响并不大，可以按照实际情况相应调节。</p>
<p>ThreadsPerChild是worker MPM中与性能相关最密切的指令。ThreadsPerChild的最大缺省值是64，如果负载较大，64也是不够的。这时要显式使用 ThreadLimit指令，它的最大缺省值是20000。上述两个值位于源码树server/mpm/worker/worker.c中的以下两行：</p>
<p>#define DEFAULT_THREAD_LIMIT 64</p>
<p>#define MAX_THREAD_LIMIT 20000</p>
<p>这两行对应着ThreadsPerChild和ThreadLimit的限制数。最好在configure之前就把64改成所希望的值。注意，不要把这两个值设得太高而超过系统的处理能力，从而导致因Apache不起动而使系统不稳定。</p>
<p>Worker模式下所能同时处理的请求总数是由子进程总数乘以ThreadsPerChild值决定的，应该大于等于MaxClients。如果负载很大，现有的子进程数不能满足时，主控进程会派生新的子进程。默认最大的子进程总数是16，加大时也需要显式声明ServerLimit（最大值是20000）。这两个值位于源码树server/mpm/worker/worker.c中的以下两行：</p>
<p>#define DEFAULT_SERVER_LIMIT 16</p>
<p>#define MAX_SERVER_LIMIT 20000</p>
<p>以上内容我也是从我以前文档里cp的，也许有点过时，对于初次学习还是有帮助的。HOHOHO</p>
<p>好了，以下是我的机器实际配置过程。</p>
<p>我使用的MPM是worker，我要通过修改源代码文件，尽量增大进程数和线程数，</p>
<p>修改文件为；/root/httpd-2.0.59/server/mpm/worker/worker.c</p>
<p>修改内容：</p>
<p>#define DEFAULT_SERVER_LIMIT 50</p>
<p>#define DEFAULT_THREAD_LIMIT 100</p>
<p>然后开始编译，安装咯……</p>
<p>安装完成后，我将配置文件中worker 修改为以下；</p>
<blockquote><p>&lt;IfModule worker.c&gt;</p>
<p>StartServers        10</p>
<p>MaxClients          900</p>
<p>ServerLimit         50</p>
<p>MinSpareThreads     25</p>
<p>MaxSpareThreads     75</p>
<p>ThreadsPerChild     90</p>
<p>ThreadLimit        100</p>
<p>MaxRequestsPerChild  0</p>
<p>&lt;/IfModule&gt;</p></blockquote>
<p>具体参数说明，以上文档有。这里就不说了。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.haohtml.com/index.php/archives/4667/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>apache你必须知道的一些知识</title>
		<link>http://blog.haohtml.com/index.php/archives/4663</link>
		<comments>http://blog.haohtml.com/index.php/archives/4663#comments</comments>
		<pubDate>Wed, 14 Jul 2010 09:53:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[服务器类]]></category>
		<category><![CDATA[apache]]></category>

		<guid isPermaLink="false">http://blog.haohtml.com/?p=4663</guid>
		<description><![CDATA[一下是网管的一些面试题的,大部分和apache 有关,所以记下来供学习参考之用. 1,你认为组成web站点体系有哪些元素？ 2,这样的配置，在apache起来后会有几个子进程？ （别把这个问题想的简单化) &#60;IfModule mpm_prefork_module&#62; StartServers          5 MinSpareServers       50 MaxSpareServers      100 MaxClients          150 MaxRequestsPerChild   0 &#60;/IfModule&#62; 3,在apache的worker MPM中，为什么ServerLimit要放到配置段最前面？ 4,千兆网卡的极限pps是多少？是如何算出来的？ 5,为什么lighttpd,nginx的并发性能比apache要高？ 6,top命令里running的值表示什么意思？这个值和CPU数有什么关系？ 7,在http header头里看到的：Last-Modified，Expires，max-age，etag这四者有什么关系？ 8,一个web站点，如何计算所需要的带宽？公式是什么？ 9,如何看http的并发连接数的？ 10,FIN_WAIT2是在什么状态？ 11,iostat看到的： wsec/s = 600 那么wKB/s = ? 12,当打开apache的mod_status后，可以通过http://ip/server-status看到相关的状态值，那么Srv, Acc, M,SS,Req各表示什么含义？ 13,如何计算客户端到服务器段的带宽？ 阿当(593294949) 14:59:48 学学linux 内核 挨踢民工(512633589) 15:00:24 1,你认为组成web站点体系有哪些元素？ 2,这样的配置，在apache起来后会有几个子进程？ （别把这个问题想的简单化) &#60;IfModule mpm_prefork_module&#62; StartServers          5 MinSpareServers       50 MaxSpareServers      [...]]]></description>
			<content:encoded><![CDATA[<p>一下是网管的一些面试题的,大部分和apache 有关,所以记下来供学习参考之用.</p>
<p>1,你认为组成web站点体系有哪些元素？</p>
<p>2,这样的配置，在apache起来后会有几个子进程？ （别把这个问题想的简单化)<br />
&lt;IfModule mpm_prefork_module&gt;<br />
StartServers          5<br />
MinSpareServers       50<br />
MaxSpareServers      100<br />
MaxClients          150<br />
MaxRequestsPerChild   0<br />
&lt;/IfModule&gt;</p>
<p>3,在apache的worker MPM中，为什么ServerLimit要放到配置段最前面？</p>
<p>4,千兆网卡的极限pps是多少？是如何算出来的？</p>
<p>5,为什么lighttpd,nginx的并发性能比apache要高？</p>
<p>6,top命令里running的值表示什么意思？这个值和CPU数有什么关系？<br />
<span id="more-4663"></span></p>
<p>7,在http header头里看到的：Last-Modified，Expires，max-age，etag这四者有什么关系？</p>
<p>8,一个web站点，如何计算所需要的带宽？公式是什么？</p>
<p>9,如何看http的并发连接数的？</p>
<p>10,FIN_WAIT2是在什么状态？</p>
<p>11,iostat看到的：<br />
wsec/s = 600<br />
那么wKB/s = ?</p>
<p>12,当打开apache的mod_status后，可以通过http://ip/server-status看到相关的状态值，那么Srv, Acc, M,SS,Req各表示什么含义？</p>
<p>13,如何计算客户端到服务器段的带宽？</p>
<p>阿当(593294949) 14:59:48<br />
学学linux 内核<br />
挨踢民工(512633589) 15:00:24<br />
1,你认为组成web站点体系有哪些元素？</p>
<p>2,这样的配置，在apache起来后会有几个子进程？ （别把这个问题想的简单化)<br />
&lt;IfModule mpm_prefork_module&gt;<br />
StartServers          5<br />
MinSpareServers       50<br />
MaxSpareServers      100<br />
MaxClients          150<br />
MaxRequestsPerChild   0<br />
&lt;/IfModule&gt;</p>
<p>3,在apache的worker MPM中，为什么ServerLimit要放到配置段最前面？</p>
<p>4,千兆网卡的极限pps是多少？是如何算出来的？</p>
<p>5,为什么lighttpd,nginx的并发性能比apache要高？</p>
<p>6,top命令里running的值表示什么意思？这个值和CPU数有什么关系？</p>
<p>7,在http header头里看到的：Last-Modified，Expires，max-age，etag这四者有什么关系？</p>
<p>8,一个web站点，如何计算所需要的带宽？公式是什么？</p>
<p>9,如何看http的并发连接数的？</p>
<p>10,FIN_WAIT2是在什么状态？</p>
<p>11,iostat看到的：<br />
wsec/s = 600<br />
那么wKB/s = ?</p>
<p>12,当打开apache的mod_status后，可以通过http://ip/server-status看到相关的状态值，那么Srv, Acc, M,SS,Req各表示什么含义？</p>
<p>13,如何计算客户端到服务器段的带宽？</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.haohtml.com/index.php/archives/4663/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows下 Apache 性能优化</title>
		<link>http://blog.haohtml.com/index.php/archives/4659</link>
		<comments>http://blog.haohtml.com/index.php/archives/4659#comments</comments>
		<pubDate>Wed, 14 Jul 2010 09:39:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[服务器类]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[性能优化]]></category>

		<guid isPermaLink="false">http://blog.haohtml.com/?p=4659</guid>
		<description><![CDATA[一般来说，WinNT系统下使用IIS，而Apache在Linux下应用的比较多，但是依然有很多人在WinNT系统下使用Apache而非IIS，可能是基于对Windows系统的熟悉吧。今天就来说一下在Windows系统下如果优化Apache的性能。 mpm_winnt.c 是专门针对Windows NT优化的MPM(多路处理模块)，它使用一个单独的父进程产生一个单独的子进程，在这个子进程中轮流产生多个线程来处理请求。也就是说 mpm_winnt只能启动父子两个进程, 不能像Linux下那样同时启动多个进程。 mpm_winnt主要通过ThreadsPerChild和MaxRequestsPerChild两个参数来优化Apache，下面详细来说明一下。 ThreadsPerChild 这个参数用于设置每个进程的线程数, 子进程在启动时建立这些线程后就不再建立新的线程了. 一方面因为mpm_winnt不能启动多个进程, 所以这个数值要足够大，以便可以处理可能的请求高峰; 另一方面该参数以服务器的响应速度为准的, 数目太大的反而会变慢。因此需要综合均衡一个合理的数值。 mpm_winnt上的默认值是64, 最大值是1920. 这里建议设置为100-500之间，服务器性能高的话值大一些，反之值小一些。 MaxRequestsPerChild 该参数表示每个子进程能够处理的最大请求数, 即同时间内子进程数目.设置为零表示不限制, mpm_winnt上的默认值就是0。 官方参考手册中不建议设置为0, 主要基于两点考虑: (1) 可以防止(偶然的)内存泄漏无限进行，从而耗尽内存; (2) 给进程一个有限寿命，从而有助于当服务器负载减轻的时候减少活动进程的数量。 因此这个参数的值更大程度上取决于服务器的内存，如果内存比较大的话可以设置为0或很大的数字，否则设置一个小的数值。需要说明的是，如果这个值设置的太小的话会造成Apache频繁重启，在日志文件中会看到如下的文字： Process exiting because it reached MaxRequestsPerChild. Signaling the parent 这样一来降低了Apache的总体性能。 另外，可以通过查看Apache提供的server-status(状态报告)来验证当前所设置数值是否合理，在httpd.conf文件中做如下设置来打开它： # 首先需要加载mod_status模块 LoadModule status_module modules/mod_status.so # 然后设置访问的地址 SetHandler server-status Order deny,allow Deny from all # 如果限制某个IP访问则设置为 [...]]]></description>
			<content:encoded><![CDATA[<p>一般来说，WinNT系统下使用IIS，而Apache在Linux下应用的比较多，但是依然有很多人在WinNT系统下使用Apache而非IIS，可能是基于对Windows系统的熟悉吧。今天就来说一下在Windows系统下如果优化Apache的性能。</p>
<p><span style="color: #ff6600;"><strong><span style="color: #333300;"><span style="text-decoration: underline;"><span style="color: #0000ff;">mpm_winnt.c</span></span></span></strong></span><span style="color: #333300;"><span style="text-decoration: underline;"><span style="color: #0000ff;"> </span></span></span>是专门针对Windows NT优化的MPM(多路处理模块)，它使用一个单独的父进程产生一个单独的子进程，在这个子进程中轮流产生多个线程来处理请求。也就是说 mpm_winnt只能启动父子两个进程, 不能像Linux下那样同时启动多个进程。</p>
<p>mpm_winnt主要通过ThreadsPerChild和MaxRequestsPerChild两个参数来优化Apache，下面详细来说明一下。</p>
<p><strong><span style="color: #ff0000;">ThreadsPerChild</span></strong></p>
<p>这个参数用于设置每个进程的线程数, 子进程在启动时建立这些线程后就不再建立新的线程了. 一方面因为mpm_winnt不能启动多个进程, 所以这个数值要足够大，以便可以处理可能的请求高峰; 另一方面该参数以服务器的响应速度为准的, 数目太大的反而会变慢。因此需要综合均衡一个合理的数值。<br />
mpm_winnt上的<span style="color: #0000ff;">默认值是64, 最大值是1920</span>. 这里建议设置为100-500之间，服务器性能高的话值大一些，反之值小一些。<span id="more-4659"></span></p>
<p><span style="color: #ff0000;"><strong>MaxRequestsPerChild</strong></span></p>
<p>该参数表示每个子进程能够处理的最大请求数, 即同时间内子进程数目.设置为零表示不限制, mpm_winnt上的默认值就是0。</p>
<p>官方参考手册中不建议设置为0, 主要基于两点考虑: (1) 可以防止(偶然的)内存泄漏无限进行，从而耗尽内存; (2) 给进程一个有限寿命，从而有助于当服务器负载减轻的时候减少活动进程的数量。</p>
<p>因此这个参数的值更大程度上取决于服务器的内存，如果内存比较大的话可以设置为0或很大的数字，否则设置一个小的数值。需要说明的是，如果这个值设置的太小的话会造成Apache频繁重启，在日志文件中会看到如下的文字：</p>
<p>Process exiting because it reached MaxRequestsPerChild. Signaling the parent</p>
<p>这样一来降低了Apache的总体性能。</p>
<p>另外，可以通过查看Apache提供的server-status(状态报告)来验证当前所设置数值是否合理，在httpd.conf文件中做如下设置来打开它：</p>
<p># 首先需要加载mod_status模块<br />
<strong>LoadModule status_module modules/mod_status.so</strong></p>
<p># 然后设置访问的地址</p>
<blockquote><p>SetHandler server-status<br />
Order deny,allow<br />
Deny from all</p></blockquote>
<p># 如果限制某个IP访问则设置为 Allow from 192.168.1.1<br />
Allow from all<br />
综合来说，因为Windows NT下Apache只能启动父子两个进程，因此只能通过增大单个进程的线程数以及单个进程能够处理的最大请求数来进行优化。其他优化的参数同Linux系统下是一样的，大家可以加以参考。</p>
<p>下面针对上述两个参数给出一个建议的设置：</p>
<blockquote><p><span style="color: #0000ff;"><span style="color: #0000ff;">&lt;IfModule mpm_winnt_module&gt;<br />
ThreadsPerChild 250<br />
MaxRequestsPerChild 5000<br />
</span></span><span style="color: #0000ff;">&lt;/IfModule&gt;</span></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.haohtml.com/index.php/archives/4659/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>apache工作方式</title>
		<link>http://blog.haohtml.com/index.php/archives/4656</link>
		<comments>http://blog.haohtml.com/index.php/archives/4656#comments</comments>
		<pubDate>Wed, 14 Jul 2010 06:17:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[服务器类]]></category>
		<category><![CDATA[apache]]></category>

		<guid isPermaLink="false">http://blog.haohtml.com/?p=4656</guid>
		<description><![CDATA[1、prefork.c模块(一个非线程型的、预派生的MPM) prefork MPM 使用多个子进程，每个子进程只有一个线程。每个进程在某个确定的时间只能维持一个连接。在大多数平台上，Prefork MPM在效率上要比Worker MPM要高，但是内存使用大得多。prefork的无线程设计在某些情况下将比worker更有优势：它可以使用那些没有处理好线程安全的第三方模块，并且对于那些线程调试困难的平台而言，它也更容易调试一些。 &#60;IfModule prefork.c&#62; ServerLimit 20000 StartServers   5 MinSpareServers   5 MaxSpareServers   10 MaxClients   1000 MaxRequestsPerChild 0 &#60;/IfModule&#62; ServerLimit 2000 //默认的MaxClient最大是256个线程,如果想设置更大的值，就的加上ServerLimit这个参数。20000是ServerLimit这个参数的最大值。如果需要更大，则必须编译apache,此前都是不需要重新编译Apache。 生效前提：必须放在其他指令的前面 StartServers   5 //指定服务器启动时建立的子进程数量，prefork默认为5。 MinSpareServers   5 //指定空闲子进程的最小数量，默认为5。如果当前空闲子进程数少于MinSpareServers ，那么Apache将以最大每秒一个的速度产生新的子进程。此参数不要设的太大。 MaxSpareServers   10 //设置空闲子进程的最大数量，默认为10。如果当前有超过MaxSpareServers数量的空闲子进程，那么父进程将杀死多余的子进程。此参数不要设的太大。如果你将该指令的值设置为比MinSpareServers小，Apache将会自动将其修改成&#8221;MinSpareServers+1&#8243;。 MaxClients   256 //限定同一时间客户端最大接入请求的数量(单个进程并发线程数)，默认为256。任何超过MaxClients限制的请求都将进入等候队列,一旦一个链接被释放，队列中的请求将得到服务。要增大这个值，你必须同时增大ServerLimit 。 MaxRequestsPerChild 10000 //每个子进程在其生存期内允许伺服的最大请求数量，默认为10000.到达MaxRequestsPerChild的限制后，子进程将会结束。如果MaxRequestsPerChild为&#8221;0&#8243;，子进程将永远不会结束。 将MaxRequestsPerChild设置成非零值有两个好处： 1.可以防止(偶然的)内存泄漏无限进行，从而耗尽内存。 2.给进程一个有限寿命，从而有助于当服务器负载减轻的时候减少活动进程的数量。 工作方式： 一个单独的控制进程(父进程)负责产生子进程，这些子进程用于监听请求并作出应答。Apache总是试图保持一些备用的 (spare)或者是空闲的子进程用于迎接即将到来的请求。这样客户端就不需要在得到服务前等候子进程的产生。在Unix系统中，父进程通常以root身份运行以便邦定80端口，而 Apache产生的子进程通常以一个低特权的用户运行。User和Group指令用于设置子进程的低特权用户。运行子进程的用户必须要对它所服务的内容有读取的权限，但是对服务内容之外的其他资源必须拥有尽可能少的权限。 2、worker.c模块(支持混合的多线程多进程的多路处理模块) worker MPM 使用多个子进程，每个子进程有多个线程。每个线程在某个确定的时间只能维持一个连接。通常来说，在一个高流量的HTTP服务器上，Worker MPM是个比较好的选择，因为Worker MPM的内存使用比Prefork MPM要低得多。但worker MPM也由不完善的地方，如果一个线程崩溃，整个进程就会连同其所有线程一起&#8221;死掉&#8221;.由于线程共享内存空间，所以一个程序在运行时必须被系统识别为&#8221;每个线程都是安全的&#8221;。 &#60;IfModule worker.c&#62; ServerLimit [...]]]></description>
			<content:encoded><![CDATA[<div>
<div><strong>1</strong><strong>、prefork.c模块(一个非线程型的、预派生的MPM)</strong><strong><br />
</strong> prefork MPM 使用多个子进程，每个子进程只有一个线程。每个进程在某个确定的时间只能维持一个连接。在大多数平台上，Prefork MPM在效率上要比Worker MPM要高，但是内存使用大得多。prefork的无线程设计在某些情况下将比worker更有优势：它可以使用那些没有处理好线程安全的第三方模块，并且对于那些线程调试困难的平台而言，它也更容易调试一些。<span id="more-4656"></span></div>
<div>&lt;IfModule prefork.c&gt;<br />
<a name="baidusnap1"></a><strong>ServerLimit</strong> 20000<br />
StartServers   5<br />
MinSpareServers   5<br />
MaxSpareServers   10<br />
MaxClients   1000<br />
MaxRequestsPerChild 0<br />
&lt;/IfModule&gt;</div>
<div><strong>ServerLimit</strong> 2000<br />
//默认的MaxClient最大是256个线程,如果想设置更大的值，就的加上<strong>ServerLimit</strong>这个参数。20000是<strong>ServerLimit</strong>这个参数的最大值。如果需要更大，则必须编译<strong>apache</strong>,此前都是不需要重新编译<strong>Apache</strong>。<br />
生效前提：必须放在其他指令的前面</div>
<div>StartServers   5<br />
//指定服务器启动时建立的子进程数量，prefork默认为5。</div>
<div>MinSpareServers   5<br />
//指定空闲子进程的最小数量，默认为5。如果当前空闲子进程数少于MinSpareServers ，那么<strong>Apache</strong>将以最大每秒一个的速度产生新的子进程。此参数不要设的太大。</div>
<div>MaxSpareServers   10<br />
//设置空闲子进程的最大数量，默认为10。如果当前有超过MaxSpareServers数量的空闲子进程，那么父进程将杀死多余的子进程。此参数不要设的太大。如果你将该指令的值设置为比MinSpareServers小，<strong>Apache</strong>将会自动将其修改成&#8221;MinSpareServers+1&#8243;。</div>
<div>MaxClients   256<br />
//限定同一时间客户端最大接入请求的数量(单个进程并发线程数)，默认为256。任何超过MaxClients限制的请求都将进入等候队列,一旦一个链接被释放，队列中的请求将得到服务。要增大这个值，你必须同时增大<strong>ServerLimit</strong> 。</div>
<div>MaxRequestsPerChild 10000<br />
//每个子进程在其生存期内允许伺服的最大请求数量，默认为10000.到达MaxRequestsPerChild的限制后，子进程将会结束。如果MaxRequestsPerChild为&#8221;0&#8243;，子进程将永远不会结束。</div>
<div>将MaxRequestsPerChild设置成非零值有两个好处：<br />
1.可以防止(偶然的)内存泄漏无限进行，从而耗尽内存。<br />
2.给进程一个有限寿命，从而有助于当服务器负载减轻的时候减少活动进程的数量。</div>
<div>工作方式：<br />
一个单独的控制进程(父进程)负责产生子进程，这些子进程用于监听请求并作出应答。<strong>Apache</strong>总是试图保持一些备用的 (spare)或者是空闲的子进程用于迎接即将到来的请求。这样客户端就不需要在得到服务前等候子进程的产生。在Unix系统中，父进程通常以root身份运行以便邦定80端口，而 <strong>Apache</strong>产生的子进程通常以一个低特权的用户运行。User和Group指令用于设置子进程的低特权用户。运行子进程的用户必须要对它所服务的内容有读取的权限，但是对服务内容之外的其他资源必须拥有尽可能少的权限。</div>
<div>
<strong>2</strong><strong>、worker.c模块(支持混合的多线程多进程的多路处理模块)</strong><br />
worker MPM 使用多个子进程，每个子进程有多个线程。每个线程在某个确定的时间只能维持一个连接。通常来说，在一个高流量的HTTP服务器上，Worker MPM是个比较好的选择，因为Worker MPM的内存使用比Prefork MPM要低得多。但worker MPM也由不完善的地方，如果一个线程崩溃，整个进程就会连同其所有线程一起&#8221;死掉&#8221;.由于线程共享内存空间，所以一个程序在运行时必须被系统识别为&#8221;每个线程都是安全的&#8221;。</div>
<div>&lt;IfModule worker.c&gt;<br />
<strong>ServerLimit</strong> 50<br />
ThreadLimit   200<br />
StartServers   5<br />
MaxClients   5000<br />
MinSpareThreads   25<br />
MaxSpareThreads   500<br />
ThreadsPerChild   100<br />
MaxRequestsPerChild 0<br />
&lt;/IfModule&gt;</div>
<div><strong>ServerLimit</strong> 16<br />
//服务器允许配置的进程数上限。这个指令和ThreadLimit结合使用设置了MaxClients最大允许配置的数值。任何在重启期间对这个指令的改变都将被忽略，但对MaxClients的修改却会生效。</div>
<div>ThreadLimit 64<br />
//每个子进程可配置的线程数上限。这个指令设置了每个子进程可配置的线程数ThreadsPerChild上限。任何在重启期间对这个指令的改变都将被忽略，但对ThreadsPerChild的修改却会生效。默认值是&#8221;64&#8243;.</div>
<div>StartServers 3<br />
//服务器启动时建立的子进程数，默认值是&#8221;3&#8243;。</div>
<div>MinSpareThreads 75<br />
//最小空闲线程数,默认值是&#8221;75&#8243;。这个MPM将基于整个服务器监视空闲线程数。如果服务器中总的空闲线程数太少，子进程将产生新的空闲线程。</div>
<div>MaxSpareThreads 250<br />
//设置最大空闲线程数。默认值是&#8221;250&#8243;。这个MPM将基于整个服务器监视空闲线程数。如果服务器中总的空闲线程数太多，子进程将杀死多余的空闲线程。MaxSpareThreads的取值范围是有限制的。<strong>Apache</strong>将按照如下限制自动修正你设置的值：worker要求其大于等于 MinSpareThreads加上ThreadsPerChild的和</div>
<div>MaxClients 400<br />
//允许同时伺服的最大接入请求数量(最大线程数量)。任何超过MaxClients限制的请求都将进入等候队列。默认值是&#8221;400&#8243;,16 (<strong>ServerLimit</strong>)乘以25(ThreadsPerChild)的结果。因此要增加MaxClients的时候，你必须同时增加 <strong>ServerLimit</strong>的值。</div>
<div>ThreadsPerChild 25<br />
//每个子进程建立的常驻的执行线程数。默认值是25。子进程在启动时建立这些线程后就不再建立新的线程了。</div>
<div>MaxRequestsPerChild 0<br />
//设置每个子进程在其生存期内允许伺服的最大请求数量。到达MaxRequestsPerChild的限制后，子进程将会结束。如果MaxRequestsPerChild为&#8221;0&#8243;，子进程将永远不会结束。</div>
<div>将MaxRequestsPerChild设置成非零值有两个好处：<br />
1.可以防止(偶然的)内存泄漏无限进行，从而耗尽内存。<br />
2.给进程一个有限寿命，从而有助于当服务器负载减轻的时候减少活动进程的数量。<br />
注意<br />
对于KeepAlive链接，只有第一个请求会被计数。事实上，它改变了每个子进程限制最大链接数量的行为。</div>
<div>工作方式：<br />
每个进程可以拥有的线程数量是固定的。服务器会根据负载情况增加或减少进程数量。一个单独的控制进程(父进程)负责子进程的建立。每个子进程可以建立 ThreadsPerChild数量的服务线程和一个监听线程，该监听线程监听接入请求并将其传递给服务线程处理和应答。<strong>Apache</strong>总是试图维持一个备用(spare)或是空闲的服务线程池。这样，客户端无须等待新线程或新进程的建立即可得到处理。在Unix中，为了能够绑定80端口，父进程一般都是以 root身份启动，随后，<strong>Apache</strong>以较低权限的用户建立子进程和线程。User和Group指令用于设置<strong>Apache</strong>子进程的权限。虽然子进程必须对其提供的内容拥有读权限，但应该尽可能给予它较少的特权。另外，除非使用了suexec ，否则，这些指令设置的权限将被CGI脚本所继承。</div>
<div><strong>3</strong><strong>、perchild.c模块</strong></div>
<div>
公式：<br />
ThreadLimit &gt;= ThreadsPerChild<br />
MaxClients &lt;= <strong>ServerLimit</strong> * ThreadsPerChild 必须是ThreadsPerChild的倍数<br />
MaxSpareThreads &gt;= MinSpareThreads+ThreadsPerChild</div>
<div>硬限制：</div>
<div>ServerLimi和ThreadLimit这两个指令决定了活动子进程数量和每个子进程中线程数量的硬限制。要想改变这个硬限制必须完全停止服务器然后再启动服务器(直接重启是不行的)。</div>
<div><strong>Apache</strong>在编译<strong>ServerLimit</strong>时内部有一个硬性的限制，你不能超越这个限制。<br />
prefork MPM最大为&#8221;<strong>ServerLimit</strong> 200000&#8243;<br />
其它MPM(包括work MPM)最大为&#8221;<strong>ServerLimit</strong> 20000</div>
<div><strong>Apache</strong>在编译ThreadLimit时内部有一个硬性的限制，你不能超越这个限制。<br />
mpm_winnt是&#8221;ThreadLimit 15000&#8243;<br />
其它MPM(包括work prefork)为&#8221;ThreadLimit 20000</div>
<div>注意<br />
使用<strong>ServerLimit</strong>和ThreadLimit时要特别当心。如果将<strong>ServerLimit</strong>和ThreadLimit设置成一个高出实际需要许多的值，将会有过多的共享内存被分配。当设置成超过系统的处理能力，<strong>Apache</strong>可能无法启动，或者系统将变得不稳定。</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.haohtml.com/index.php/archives/4656/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nginx和Apache简单的并发压力测试</title>
		<link>http://blog.haohtml.com/index.php/archives/4643</link>
		<comments>http://blog.haohtml.com/index.php/archives/4643#comments</comments>
		<pubDate>Wed, 14 Jul 2010 04:17:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[服务器类]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[压力测试]]></category>

		<guid isPermaLink="false">http://blog.haohtml.com/?p=4643</guid>
		<description><![CDATA[来源:http://www.javaeye.com/topic/255556 同样的环境，大小差不了几个字节的页面， Nginx的worker_connections  1024; Apache的MaxClients          150，worker模式； 照理说压Nginx如果用1024个并发压效果是最好的，同样压apache并发150的话效果也是最好的。 Nginx的测试结果： [root@localhost nginx-0.7.19]# ab -t 60 -c 1024 http://192.168.1.101:8080/ This is ApacheBench, Version 2.0.40-dev &#60;$Revision: 1.116 $&#62; apache-2.0 Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/Benchmarking 192.168.1.101 (be patient)Completed 5000 requests Completed 10000 requests Completed 15000 requests Completed 20000 requests Completed 25000 requests Completed 30000 requests Completed 35000 requests Completed 40000 requests Completed 45000 requests Finished 50000 requests Server Software: nginx/0.7.19 Server Hostname: 192.168.1.101 Server Port: 8080 Document Path: / Document Length: 151 bytes Concurrency Level: 1024 Time taken for tests: 28.791802 seconds Complete requests: 50000 Failed requests: 0 Write errors: 0 Total transferred: 18100000 bytes HTML transferred: 7550000 bytes Requests per second: 1736.61 [#/sec] (mean) Time per request: 589.656 [ms] (mean) Time per request: 0.576 [ms] (mean, across all concurrent requests) Transfer rate: 613.89 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 19.0 0 2998 Processing: 33 531 448.3 458 3452 Waiting: 10 298 457.2 237 3415 Total: 33 531 448.7 458 3452 Percentage of the requests served within a certain time (ms) 50% 458 66% 466 75% 478 80% 483 90% 502 95% 599 98% 3409 99% 3428 100% 3452 (longest request) Nginx 50000个请求只花费了28秒就搞定。 Apache的测试结果： [root@localhost nginx-0.7.19]# [...]]]></description>
			<content:encoded><![CDATA[<p>来源:<a href="http://www.javaeye.com/topic/255556">http://www.javaeye.com/topic/255556</a></p>
<p>同样的环境，大小差不了几个字节的页面，</p>
<p>Nginx的worker_connections  1024;</p>
<p>Apache的MaxClients          150，worker模式；</p>
<p>照理说压Nginx如果用1024个并发压效果是最好的，同样压apache并发150的话效果也是最好的。<span id="more-4643"></span></p>
<p>Nginx的测试结果：</p>
<div>
<ol>
<li>[root@localhost nginx-0.7.19]# <span style="color: #0000ff;">ab -t 60 -c 1024 http://192.168.1.101:8080/</span></li>
<li>This is ApacheBench, Version 2.0.40-dev &lt;$Revision: 1.116 $&gt; apache-2.0 Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/Benchmarking 192.168.1.101 (be patient)Completed 5000 requests<br />
Completed 10000 requests<br />
Completed 15000 requests<br />
Completed 20000 requests<br />
Completed 25000 requests<br />
Completed 30000 requests<br />
Completed 35000 requests<br />
Completed 40000 requests<br />
Completed 45000 requests<br />
Finished 50000 requests</p>
<p>Server Software: nginx/0.7.19<br />
Server Hostname: 192.168.1.101<br />
Server Port: 8080</p>
<p>Document Path: /</p>
<p>Document Length: 151 bytes</p>
<p>Concurrency Level: 1024</p>
<p>Time taken for tests: <strong>28.791802 seconds</strong></p>
<p>Complete requests: <strong>50000</strong><br />
Failed requests: 0<br />
Write errors: 0</p>
<p>Total transferred: 18100000 bytes<br />
HTML transferred: 7550000 bytes</p>
<p>Requests per second: 1736.61 [#/sec] (mean)<br />
Time per request: 589.656 [ms] (mean)<br />
Time per request: 0.576 [ms] (mean, across all concurrent requests)</p>
<p>Transfer rate: 613.89 [Kbytes/sec] received</p>
<p>Connection Times (ms)<br />
min mean[+/-sd] median max</p>
<p>Connect: 0 0 19.0 0 2998<br />
Processing: 33 531 448.3 458 3452<br />
Waiting: 10 298 457.2 237 3415<br />
Total: 33 531 448.7 458 3452<br />
Percentage of the requests served within a certain time (ms)</p>
<p>50% 458<br />
66% 466<br />
75% 478<br />
80% 483<br />
90% 502<br />
95% 599<br />
98% 3409<br />
99% 3428<br />
100% 3452 (longest request)</li>
</ol>
</div>
<p>Nginx 50000个请求只花费了28秒就搞定。</p>
<p>Apache的测试结果：</p>
<div>
<ol>
<li>[root@localhost nginx-0.7.19]#<span style="color: #0000ff;"> ab -t 60 -c 150 http://192.168.1.101/</span></li>
<li>This is ApacheBench, Version 2.0.40-dev &lt;$Revision: 1.116 $&gt; apache-2.0 Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/Benchmarking 192.168.1.101 (be patient)Completed 5000 requests<br />
Completed 10000 requests<br />
Completed 15000 requests<br />
Completed 20000 requests<br />
Completed 25000 requests<br />
Completed 30000 requests<br />
Completed 35000 requests<br />
Finished 39842 requests</p>
<p>Server Software: Apache/2.2.10<br />
Server Hostname: 192.168.1.101</p>
<p>Server Port: 80<br />
Document Path: /</p>
<p>Document Length: 44 bytes<br />
Concurrency Level: 150</p>
<p>Time taken for tests: <strong>60.74169 seconds</strong><br />
Complete requests: <strong>39842</strong></p>
<p>Failed requests: 0<br />
Write errors: 0</p>
<p>Total transferred: 11953500 bytes<br />
HTML transferred: 1753180 bytes</p>
<p>Requests per second: 663.21 [#/sec] (mean)<br />
Time per request: 226.172 [ms] (mean)</p>
<p>Time per request: 1.508 [ms] (mean, across all concurrent requests)<br />
Transfer rate: 194.31 [Kbytes/sec] received</p>
<p>Connection Times (ms)<br />
min mean[+/-sd] median max</p>
<p>Connect: 0 0 47.5 0 3000<br />
Processing: 62 223 696.2 111 12013</p>
<p>Waiting: 0 156 605.3 58 9025<br />
Total: 62 224 701.2 111 12013</p>
<p>Percentage of the requests served within a certain time (ms)<br />
50% 111</p>
<p>66% 119</p>
<p>75% 125</p>
<p>80% 129</p>
<p>90% 159</p>
<p>95% 191</p>
<p>98% 3011</p>
<p>99% 3017</p>
<p>100% 12013 (longest request)</li>
</ol>
</div>
<p>Apache一分钟只搞定了40000个请求。</p>
<p>=====================================================</p>
<p>再试试，Nginx的并发150时候的速度：</p>
<div>
<ol>
<li>[root@localhost nginx-0.7.19]# <span style="color: #0000ff;">ab -t 60 -c 150 http://192.168.1.101:8080/</span></li>
<li>This is ApacheBench, Version 2.0.40-dev &lt;$Revision: 1.116 $&gt; apache-2.0 Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/Benchmarking 192.168.1.101 (be patient)Completed 5000 requestsCompleted 10000 requestsCompleted 15000 requestsCompleted 20000 requests
<p>Completed 25000 requests</p>
<p>Completed 30000 requests</p>
<p>Completed 35000 requests</p>
<p>Completed 40000 requests</p>
<p>Completed 45000 requests</p>
<p>Finished 50000 requests</p>
<p>Server Software: nginx/0.7.19</p>
<p>Server Hostname: 192.168.1.101</p>
<p>Server Port: 8080</p>
<p>Document Path: /</p>
<p>Document Length: 151 bytes</p>
<p>Concurrency Level: 150</p>
<p>Time taken for tests: <strong>27.603372 seconds</strong></p>
<p>Complete requests: <strong>50000</strong></p>
<p>Failed requests: 0</p>
<p>Write errors: 0</p>
<p>Total transferred: 18100000 bytes</p>
<p>HTML transferred: 7550000 bytes</p>
<p>Requests per second: 1811.37 [#/sec] (mean)</p>
<p>Time per request: 82.810 [ms] (mean)</p>
<p>Time per request: 0.552 [ms] (mean, across all concurrent requests)</p>
<p>Transfer rate: 640.32 [Kbytes/sec] received</p>
<p>Connection Times (ms)</p>
<p>min mean[+/-sd] median max</p>
<p>Connect: 0 0 19.0 0 2998</p>
<p>Processing: 3 81 222.2 63 3066</p>
<p>Waiting: 0 47 216.0 31 3021</p>
<p>Total: 3 81 223.0 63 3066</p>
<p>Percentage of the requests served within a certain time (ms)</p>
<p>50% 63</p>
<p>66% 64</p>
<p>75% 65</p>
<p>80% 66</p>
<p>90% 70</p>
<p>95% 75</p>
<p>98% 86</p>
<p>99% 91</p>
<p>100% 3066 (longest request)</li>
</ol>
</div>
<p>此次和上次Nginx1024个并发相比快了一秒钟，27秒搞定50000个请求</p>
<p>再试试，Apache的并发1024时候的速度：</p>
<p>我估计会被压死，先把帖子发出去，没压死再修改。。。</p>
<div>
<ol>
<li>[root@localhost nginx-0.7.19]# <span style="color: #0000ff;">ab -t 60 -c 1024 http://192.168.1.101/</span></li>
<li>This is ApacheBench, Version 2.0.40-dev &lt;$Revision: 1.116 $&gt; apache-2.0 Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/Benchmarking 192.168.1.101 (be patient)Finished 2737 requestsServer Software: Apache/2.2.10Server Hostname: 192.168.1.101Server Port: 80
<p>Document Path: /</p>
<p>Document Length: 44 bytes</p>
<p>Concurrency Level: 1024</p>
<p>Time taken for tests:<strong> 75.767759 seconds</strong></p>
<p>Complete requests: <strong>2737</strong></p>
<p>Failed requests: 0</p>
<p>Write errors: 0</p>
<p>Total transferred: 821100 bytes</p>
<p>HTML transferred: 120428 bytes</p>
<p>Requests per second: 36.12 [#/sec] (mean)</p>
<p>Time per request: 28347.164 [ms] (mean)</p>
<p>Time per request: 27.683 [ms] (mean, across all concurrent requests)</p>
<p>Transfer rate: 10.57 [Kbytes/sec] received</p>
<p>Connection Times (ms)</p>
<p>min mean[+/-sd] median max</p>
<p>Connect: 0 20 248.8 0 3002</p>
<p>Processing: 15158 20495 5117.8 18237 36418</p>
<p>Waiting: 23 9583 5978.2 9136 21205</p>
<p>Total: 15158 20516 5119.1 18238 39402</p>
<p>Percentage of the requests served within a certain time (ms)</p>
<p>50% 18238</p>
<p>66% 21138</p>
<p>75% 21187</p>
<p>80% 21197</p>
<p>90% 24196</p>
<p>95% 36319</p>
<p>98% 36415</p>
<p>99% 36417 100% 39402 (longest request)</li>
</ol>
</div>
<p>居然没有死机！ 结论：在我本机当前环境下，Nginx处理高并发小请求的速度要快于Apache。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.haohtml.com/index.php/archives/4643/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>apache prefork优化及压力测试</title>
		<link>http://blog.haohtml.com/index.php/archives/4637</link>
		<comments>http://blog.haohtml.com/index.php/archives/4637#comments</comments>
		<pubDate>Wed, 14 Jul 2010 02:11:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[服务器类]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[压力测试]]></category>

		<guid isPermaLink="false">http://blog.haohtml.com/?p=4637</guid>
		<description><![CDATA[优化apache prefork模式的参数, (384M内存openvz 的vps环境下面) &#60;IfModule mpm_prefork_module&#62; StartServers 12 MinSpareServers 12 MaxSpareServers 12 MaxClients 12 MaxRequestsPerChild 100 &#60;/IfModule&#62; StartServers是启动的进程数，Min和Max是最小最大进程数, MaxClients是最大可连接的客户端，MaxRequestPerChild是一个进程的生命周期内处理的请求数量，一旦达到设定的这个值，就回收进程。 这里的vps环境是内存384M最大可用，openvz的vps.其它优化设置可以参考http://www.netroby.com/vps 测试一千个客户端并发时的压力，可以用apache自带的ab.exe。 ab -n 1000 -c 1000 http://www.netroby.com/index.php 测试结果: Server Software: Apache/2.2.14 Server Hostname: www.netroby.com Server Port: 80 Document Path: /index.php Document Length: 0 bytes Concurrency Level: 1000 Time taken for tests: 281.953 seconds Complete requests: [...]]]></description>
			<content:encoded><![CDATA[<p>优化apache prefork模式的参数, (384M内存openvz 的vps环境下面)</p>
<p><span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; line-height: 18px; font-size: 12px; white-space: pre;">&lt;IfModule mpm_prefork_module&gt;</span></p>
<pre class="brush: bash;fontsize: 100; first-line: 1; ">StartServers         12
MinSpareServers     12
MaxSpareServers     12
MaxClients         12
MaxRequestsPerChild 100
&lt;/IfModule&gt;</pre>
<pre class="brush: bash;fontsize: 100; first-line: 1; "><span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; line-height: 19px; white-space: normal; font-size: 13px;">StartServers是启动的进程数，Min和Max是最小最大进程数, MaxClients是最大可连接的客户端，MaxRequestPerChild是一个进程的生命周期内处理的请求数量，一旦达到设定的这个值，就回收进程。<span id="more-4637"></span></span></pre>
<p>这里的vps环境是内存384M最大可用，openvz的vps.其它优化设置可以参考<a href="http://www.netroby.com/vps">http://www.netroby.com/vps</a></p>
<p>测试一千个客户端并发时的压力，可以用apache自带的ab.exe。</p>
<blockquote><p><span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; line-height: 18px; font-size: 12px; white-space: pre;">ab -n 1000 -c 1000 http://www.netroby.com/index.php</span></p></blockquote>
<p><strong>测试结果:</strong></p>
<pre class="brush: plain;fontsize: 100; first-line: 1; ">Server Software:        Apache/2.2.14
Server Hostname:        www.netroby.com
Server Port:            80

Document Path:          /index.php
Document Length:        0 bytes

Concurrency Level:      1000
Time taken for tests:   281.953 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Non-2xx responses:      1000
Total transferred:      315000 bytes
HTML transferred:       0 bytes
Requests per second:    3.55 [#/sec] (mean)
Time per request:       281953.125 [ms] (mean)
Time per request:       281.953 [ms] (mean, across all concurrent requests)
Transfer rate:          1.09 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:      250  279 210.5    266    3281
Processing:  2109 138233 80553.2 136609  279156
Waiting:     2109 137264 81108.3 135359  279125
Total:       2375 138512 80561.8 136875  279750

Percentage of the requests served within a certain time (ms)
  50%  136875
  66%  184719
  75%  208547
  80%  221641
  90%  247469
  95%  266594
  98%  274438
  99%  277063
 100%  279750 (longest request)</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.haohtml.com/index.php/archives/4637/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu下安装apache+php+mysql+phpmyadmin</title>
		<link>http://blog.haohtml.com/index.php/archives/4522</link>
		<comments>http://blog.haohtml.com/index.php/archives/4522#comments</comments>
		<pubDate>Thu, 08 Jul 2010 05:02:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[服务器类]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://blog.haohtml.com/?p=4522</guid>
		<description><![CDATA[通过这篇文章，让我这个菜鸟成功的安装好了webserver需要的各种软件，特此转载下。 在windows xp系统中可以傻瓜化安装amp，即安装wamp server这个把apache、php、mysql、phpmyadmin集成在一起的套装即可，而且在选择apache模块时还特别方便，真是可以不 用动脑了。由于ubuntu现在的操作也基本傻瓜化了，安装lamp也同样方便，但由于其linux血统，有的地方还需要注意一下。以下简单说明步骤： 1、安装apahce2。 sudo apt-get install apache2 完成后在浏览器地址栏输入127.0.0.1或localhost测试一下，如果网页上显示It works，那么ok。 2、安装php5。 sudo apt-get install php5 一般会自动安装libapache2-mod-php5。有的指南上说，安装apache2后，只安装libapache2-mod-php5即可。要注意的是，安装完php5，别忘记重启apache2。 sudo /etc/init.d/apache2 restart 完成后，在浏览器中运行一下info.php，如果出现php安装完成的各种信息，就成功了。如果你没有info.php，自己写一个，放在/var/www目录下，很简单，如下： &#60;\?php info() \?&#62; 如果总是出现提示下载info.php文件的问题，不要在浏览器地址栏输入http://localhost/info.php，直接用ip地址试 一下，即http://127.0.0.1/info.php。有的指南上说，可以先 sudo a2enmod php5，然后使用sudo /etc/init.d/apache2 restart来重新启动APACHE。总之，一般php的安装不会出现问题。 3、安装mysql。 在php5下安装mysql，在终端输入如下命令： sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql 如果root帐号没有mysql密码，还要建立一个，具体方法看指南即可。以下从指南中抄一段： mysql -u root 进入MYSQL控制台，然后输入 mysql&#62; SET PASSWORD FOR &#8216;root&#8217;@'localhost&#8217; = PASSWORD(&#8216;yourpassword&#8217;); 如果成功MYSQL会提示 Query OK, [...]]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste">
<p><span style="font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; line-height: 28px; font-size: 14px;"> </span><span style="font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; line-height: 25px; font-size: 14px; color: #444444; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">通过这篇文章，让我这个菜鸟成功的安装好了webserver需要的各种软件，特此转载下。</span></p>
<p><span style="font-family: Verdana, 'Lucida Grande', Arial, Helvetica, sans-serif; line-height: 25px; font-size: 14px; color: #444444; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"></p>
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">在windows xp系统中可以傻瓜化安装amp，即安装wamp server这个把apache、php、mysql、phpmyadmin集成在一起的套装即可，而且在选择apache模块时还特别方便，真是可以不 用动脑了。由于ubuntu现在的操作也基本傻瓜化了，安装lamp也同样方便，但由于其linux血统，有的地方还需要注意一下。以下简单说明步骤：<span id="more-4522"></span></p>
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">1、安装apahce2。</p>
<blockquote style="word-wrap: break-word; word-break: break-all; margin-top: 20px; margin-right: 30px; margin-bottom: 20px; margin-left: 30px; padding-top: 0px; padding-right: 10px; padding-bottom: 0px; padding-left: 10px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 10px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f7f7f7; background-position: initial initial; background-repeat: initial initial; border-color: #3b5998; border-style: solid;">
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">sudo apt-get install apache2</p>
</blockquote>
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">完成后在浏览器地址栏输入127.0.0.1或localhost测试一下，如果网页上显示It works，那么ok。</p>
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">2、安装php5。</p>
<blockquote style="word-wrap: break-word; word-break: break-all; margin-top: 20px; margin-right: 30px; margin-bottom: 20px; margin-left: 30px; padding-top: 0px; padding-right: 10px; padding-bottom: 0px; padding-left: 10px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 10px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f7f7f7; background-position: initial initial; background-repeat: initial initial; border-color: #3b5998; border-style: solid;">
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">sudo apt-get install php5</p>
</blockquote>
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">一般会自动安装libapache2-mod-php5。有的指南上说，安装apache2后，只安装libapache2-mod-php5即可。要注意的是，安装完php5，别忘记重启apache2。</p>
<blockquote style="word-wrap: break-word; word-break: break-all; margin-top: 20px; margin-right: 30px; margin-bottom: 20px; margin-left: 30px; padding-top: 0px; padding-right: 10px; padding-bottom: 0px; padding-left: 10px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 10px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f7f7f7; background-position: initial initial; background-repeat: initial initial; border-color: #3b5998; border-style: solid;">
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">sudo /etc/init.d/apache2 restart</p>
</blockquote>
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">完成后，在浏览器中运行一下info.php，如果出现php安装完成的各种信息，就成功了。如果你没有info.php，自己写一个，放在/var/www目录下，很简单，如下：</p>
<blockquote style="word-wrap: break-word; word-break: break-all; margin-top: 20px; margin-right: 30px; margin-bottom: 20px; margin-left: 30px; padding-top: 0px; padding-right: 10px; padding-bottom: 0px; padding-left: 10px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 10px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f7f7f7; background-position: initial initial; background-repeat: initial initial; border-color: #3b5998; border-style: solid;">
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">&lt;\?php info() \?&gt;</p>
</blockquote>
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">如果总是出现提示下载info.php文件的问题，不要在浏览器地址栏输入http://localhost/info.php，直接用ip地址试 一下，即http://127.0.0.1/info.php。有的指南上说，可以先 sudo a2enmod php5，然后使用sudo /etc/init.d/apache2 restart来重新启动APACHE。总之，一般php的安装不会出现问题。</p>
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">3、安装mysql。</p>
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">在php5下安装mysql，在终端输入如下命令：</p>
<blockquote style="word-wrap: break-word; word-break: break-all; margin-top: 20px; margin-right: 30px; margin-bottom: 20px; margin-left: 30px; padding-top: 0px; padding-right: 10px; padding-bottom: 0px; padding-left: 10px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 10px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f7f7f7; background-position: initial initial; background-repeat: initial initial; border-color: #3b5998; border-style: solid;">
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql</p>
</blockquote>
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">如果root帐号没有mysql密码，还要建立一个，具体方法看指南即可。以下从指南中抄一段：</p>
<blockquote style="word-wrap: break-word; word-break: break-all; margin-top: 20px; margin-right: 30px; margin-bottom: 20px; margin-left: 30px; padding-top: 0px; padding-right: 10px; padding-bottom: 0px; padding-left: 10px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 10px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f7f7f7; background-position: initial initial; background-repeat: initial initial; border-color: #3b5998; border-style: solid;">
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">mysql -u root</p>
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">进入MYSQL控制台，然后输入</p>
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">mysql&gt; SET PASSWORD FOR &#8216;root&#8217;@'localhost&#8217; = PASSWORD(&#8216;yourpassword&#8217;);</p>
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">如果成功MYSQL会提示</p>
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">Query OK, 0 rows affected (0.00 sec)</p>
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">MYSQL命令可以多行执行，但是请您不要忘记，一定要以“；”分号结尾哦 。</p>
</blockquote>
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">先不用建立新用户，安装phpmyadmin后，可在图形化界面下建立。</p>
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">4、安装phpmyadmin。</p>
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">这个要说一下，命令虽然很简单，如下：</p>
<blockquote style="word-wrap: break-word; word-break: break-all; margin-top: 20px; margin-right: 30px; margin-bottom: 20px; margin-left: 30px; padding-top: 0px; padding-right: 10px; padding-bottom: 0px; padding-left: 10px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 10px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f7f7f7; background-position: initial initial; background-repeat: initial initial; border-color: #3b5998; border-style: solid;">
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">sudo apt-get install phpmyadmin</p>
</blockquote>
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">但会默认安装到/usr/share目录下去，所以还要copy到/var/www目录下，先cd到/usr/share目录，用如下命令：</p>
<blockquote style="word-wrap: break-word; word-break: break-all; margin-top: 20px; margin-right: 30px; margin-bottom: 20px; margin-left: 30px; padding-top: 0px; padding-right: 10px; padding-bottom: 0px; padding-left: 10px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 10px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f7f7f7; background-position: initial initial; background-repeat: initial initial; border-color: #3b5998; border-style: solid;">
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">sudo cp  -r -a /phpmyadmin/ /var/www</p>
</blockquote>
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">-r是拷贝目录， -a 保持权限不变。然后，打开一个配置文件:</p>
<blockquote style="word-wrap: break-word; word-break: break-all; margin-top: 20px; margin-right: 30px; margin-bottom: 20px; margin-left: 30px; padding-top: 0px; padding-right: 10px; padding-bottom: 0px; padding-left: 10px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 10px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f7f7f7; background-position: initial initial; background-repeat: initial initial; border-color: #3b5998; border-style: solid;">
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">sudo gedit /etc/phpmyadmin/apache.conf</p>
</blockquote>
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">把alias一行改为如下形式，即把目录设置为/www/phpmyadmin：</p>
<blockquote style="word-wrap: break-word; word-break: break-all; margin-top: 20px; margin-right: 30px; margin-bottom: 20px; margin-left: 30px; padding-top: 0px; padding-right: 10px; padding-bottom: 0px; padding-left: 10px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 10px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f7f7f7; background-position: initial initial; background-repeat: initial initial; border-color: #3b5998; border-style: solid;">
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">Alias /phpmyadmin /var/www/phpmyadmin</p>
</blockquote>
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">重新启动apache。完成后在浏览器地址栏输入http://localhost/phpmyamin，按提示输入用户名和密码，因为前面没有建 立mysql新用户，这里输入root和root的mysql密码好了。进入图形管理界面后，建立一个用户，给他all previliges，即全部权限。 :lol:</p>
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">建立一个blog或cms或其他什么名称的数据库，供你安装wordpress或其他文章管理程序或博客使用。</p>
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">小结：</p>
<p style="word-wrap: break-word; word-break: break-all; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding: 0px;">总之，现在无论在windows还是在ubuntu上，amp服务器配置都傻瓜化了，对我们菜鸟来说当然是好事。在ubuntu下看来要注意的是： 一、安装php5，用http://127.0.0.1/info.php测试一下，如果总是用http://localhost/info.php，可 能老是提示你下载info.php文件。二、phpmyadmin管理mysql数据库很方便，但默认安装到/usr/share，所以要拷贝到/var /www下面去才能工作，也别忘记在其配置文件中把虚拟目录改为/var/www/phpmyadmin。</p>
<p></span></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.haohtml.com/index.php/archives/4522/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>解决“[warn] (OS 64)指定的网络名不再可用”错误合集</title>
		<link>http://blog.haohtml.com/index.php/archives/4335</link>
		<comments>http://blog.haohtml.com/index.php/archives/4335#comments</comments>
		<pubDate>Sun, 04 Jul 2010 03:10:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[服务器类]]></category>
		<category><![CDATA[apache]]></category>

		<guid isPermaLink="false">http://blog.haohtml.com/?p=4335</guid>
		<description><![CDATA[都是转的: 其一: 近来点击玩聚热点故事，偶尔遇到500错误，看了看Apache2.2.3日志(Windows2003下的)，注意到如下错误丫的总出现： [warn] (OS 64)指定的网络名不再可用。 : winnt_accept: Asynchronous AcceptEx failed. 以前也看到，但忽略了。这回不能再放过她了。 看了几篇（winnt(MPM) － Apache 2.2 中文版参考手册），说是因为一些流行的Windows产品，比如防病毒软件或虚拟专用网络软件，会干扰AcceptEx()的正确操作。于是在apache配置文件中添加如下语句： &#60;IfModule mpm_winnt.c&#62; ThreadsPerChild 1000 MaxRequestsPerChild   10000 Win32DisableAcceptEx &#60;/IfModule&#62; 停止Apache，再启动。确实新配置起作用了： [notice] Disabled use of AcceptEx() WinSock2 API [notice] mod_python: Creating 8 session mutexes based on 0 max processes and 1000 max threads. [notice] Child 2380: Child process is running [...]]]></description>
			<content:encoded><![CDATA[<p>都是转的:</p>
<p><strong><span style="font-size: small;">其一:</span></strong></p>
<p>近来点击玩聚热点故事，偶尔遇到500错误，看了看Apache2.2.3日志(Windows2003下的)，注意到如下错误丫的总出现：<br />
<span style="font-size: small;">[warn] (OS 64)指定的网络名不再可用。 : winnt_accept: Asynchronous  AcceptEx failed.</span><br />
<span style="font-size: small;">以前也看到，但忽略了。这回不能再放过她了。</span><br />
<span style="font-size: small;">看了几篇（</span><a href="http://www.linuxpk.com/doc/apache/mod/mpm_winnt.html" target="_blank"><span style="font-size: small;"><span style="color: #669966;">winnt(MPM) － Apache 2.2 中文版参考手册</span></span></a><span style="font-size: small;">），说是因为一些流行的Windows产品，比如防病毒软件或虚拟专用网络软件，会干扰<span style="font-family: 新宋体;">AcceptEx()</span>的正确操作。于是在apache配置文件中添加如下语句：</span><br />
<span style="font-size: small;">&lt;IfModule mpm_winnt.c&gt;<br />
ThreadsPerChild  1000<br />
MaxRequestsPerChild   10000<br />
Win32DisableAcceptEx<br />
&lt;/IfModule&gt; </span><br />
<span style="font-size: small;">停止Apache，再启动。确实新配置起作用了：</span><br />
<span style="font-size: small;">[notice]  Disabled use of AcceptEx() WinSock2 API<br />
[notice] mod_python: Creating 8  session mutexes based on 0 max processes and 1000 max threads.<br />
[notice] Child  2380: Child process is running<br />
[notice] Child 2380: Acquired the start  mutex.<br />
[notice] Child 2380: Starting 1000 worker threads. </span><br />
<span style="font-size: small;">okay，似乎错误不再来了<span id="more-4335"></span><!--more--></span></p>
<p><span style="font-size: small;"><strong>其二:</strong> </span></p>
<p><span style="font-size: small;"><span style="font-size: x-small;">在Apache的logs/error.log中经常出现如下记录：</p>
<p>[Fri Mar 16  17:28:49 2007] [warn] (OS 64)指定的网络名不再可用。     : winnt_accept:  Asynchronous AcceptEx failed.<br />
[Fri Mar 16 17:28:49 2007] [warn] (OS  64)指定的网络名不再可用。     : winnt_accept: Asynchronous AcceptEx failed.<br />
[Fri Mar 16  17:28:50 2007] [warn] (OS 64)指定的网络名不再可用。     : winnt_accept: Asynchronous  AcceptEx failed.<br />
[Fri Mar 16 17:28:50 2007] [warn] (OS 64)指定的网络名不再可用。     :  winnt_accept: Asynchronous AcceptEx failed.<br />
[Fri Mar 16 17:28:50 2007] [warn]  (OS 64)指定的网络名不再可用。     : winnt_accept: Asynchronous AcceptEx failed.<br />
[Fri Mar  16 17:28:50 2007] [warn] (OS 64)指定的网络名不再可用。     : winnt_accept: Asynchronous  AcceptEx failed.<br />
[Fri Mar 16 17:28:50 2007] [warn] (OS 64)指定的网络名不再可用。     :  winnt_accept: Asynchronous AcceptEx  failed.</p>
<p>出现这个故障时硬盘灯狂闪，内存占用极大，导致网站访问极慢。</p>
<p><span style="color: #ff0000;">解决方法：</span></p>
<p>Apache 关闭 AcceptEx()  ，这个在Windows平台下适用</p>
<p>方法是在 httpd.conf 内加入 Win32DisableAcceptEx  。</p>
<p>Win32DisableAcceptEx 顾名思义就是在 Windows 下关掉 AcceptEx() 功能的指令。至於  AcceptEx() 这个东西是什么，可以参考 Apache 的官方网页:</p>
<p></span><a href="http://httpd.apache.org/docs-2.0/mod/mpm_winnt.html#win32disableacceptex" target="_blank"><span style="color: #0000ff; font-size: x-small;">http://httpd.apache.org/docs-2.0 &#8230;  in32disableacceptex</span></a></p>
<p></span><span style="font-size: x-small;">QUOTE:<br />
AcceptEx()  is a Microsoft WinSock v2 API that provides some performance improvements over  the use of the BSD style accept() API in certain circumstances. Some popular  Windows products, typically virus scanning or virtual private network packages,  have bugs that interfere with the proper operation of AcceptEx(). If you  encounter an error condition like:</p>
<p>[error] (730038)An operation was  attempted on something that is not a socket.: winnt_accept: AcceptEx failed.  Attempting to recover.</p>
<p>you should use this directive to disable the use  of AcceptEx().</p>
<p>主要是说这 AcceptEx() 是 Microsoft WinSock v2 API 一组提升网络效率 API  中的指令。而且在 Windows 上似乎蛮有可能出问题的。</p>
<p>注：可能为了效能还是预设为开啟 AcceptEx()</p>
<p>如果无预警的发生问题，我猜可能是 Windows Update 或是防火墙、防毒软体更新了某些网路原件，造成 Microsoft WinSock v2  API 动作不正常，这时可以把这个功能先给关掉。</p>
<p>依照官方说明 ， Win32DisableAcceptEx 这个功能，只有  2.0.49 版以后的才可以使用，所以我猜测 AcceptEx() 这个指令大概也是 2.0.49 才会开始支援(目前最新的就是  2.0.49)。</p>
<p>关掉 AcceptEx() 的方式只要在 httpd.conf 找到 &amp;lt;IfModule  mpm_winnt.c&amp;gt; 区段，加入 Win32DisableAcceptEx  就可以了。</p>
<p>QUOTE:<br />
&lt;IfModule  mpm_winnt.c&gt;<br />
Win32DisableAcceptEx<br />
EnableMMAP Off<br />
EnableSendfile  Off<br />
ThreadsPerChild 1700<br />
MaxRequestsPerChild  0<br />
&lt;/IfModule&gt;</p>
<p>然后重新启动动 Apache，“指定的网络名不再可用”再也不出现了</span></p>
<p><strong><span style="font-size: small;">其三:</span></strong></p>
<p><span style="font-size: x-small;">没遇到过..帮你找了个资料不知有没有用:<br />
为了这个问题简直是伤透了心，拖拖拉拉了很长时间也没有解决，这阵子咬咬牙，查遍了相关资料，终于把一堆办法划拉到一起，似乎解决了这个问题。方法很简单，但是似乎不同的服务器有不同的解决方法。<br />
大体解决思路有这么几种：<br />
1  apache与服务器的杀毒软件和防火墙冲突，导致了windows的sock api失败<br />
2 和dhcp或者动态dns有关系<br />
3  通过apache的配置来解决<br />
4  php的bug带来的问题<br />
通过一段时间的排查，应该说基本能确认不是前两点问题。那么如何通过配置来解决呢，因为频繁出现的这个问题还导致了apache性能的下降，更不能容忍的是，我们不清楚什么时候apache会出现memory  leak。<br />
因此参考了国外网友的经验，在配置文件里面对以下几项开关选项做了设置：<br />
Win32DisableAcceptEx<br />
EnableMMAP  Off<br />
EnableSendfile Off<br />
这个方法的处理过程可以参见apache的bug  21425。<br />
问题还没有结束，因为之前配置过Win32DisableAcceptEx开关，打开之后会出现这个问题：<br />
FATAL:  erealloc(): Unable to allocate 98304  bytes<br />
如何解决这个问题呢？这里还有解决方法：<br />
将ThreadsPerChild选项从默认的250或者更多，降至170以下。<br />
ThreadsPerChild  170<br />
这样配置之后，这两个问题都不出现了。log里面不再有error和warn了。<br />
最后我还到php的官方buglist里面确认了一下，应该说最新版本的php应该不会出现一些影响apache这个问题的可能。这样，经过下午的观测，到现在为止apache工作还算正常。</span></p>
<p><span style="color: #45818e; font-size: x-small;">我用第一种方法就解决了问题.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.haohtml.com/index.php/archives/4335/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
