mpm.xml.zh-cn revision 3174ed450858787dfec8bf9701e282d25e87188b
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen<?xml version='1.0' encoding='UTF-8' ?>
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner<!DOCTYPE manualpage SYSTEM "/style/manualpage.dtd">
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner<?xml-stylesheet type="text/xsl" href="/style/manual.zh-cn.xsl"?>
9ec7787531611654e8f50932473aa48963eaba55Trond Norbye<!-- English revision : 927046 -->
9ec7787531611654e8f50932473aa48963eaba55Trond Norbye
9ec7787531611654e8f50932473aa48963eaba55Trond Norbye<!--
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen Licensed to the Apache Software Foundation (ASF) under one or more
9ec7787531611654e8f50932473aa48963eaba55Trond Norbye contributor license agreements. See the NOTICE file distributed with
9ec7787531611654e8f50932473aa48963eaba55Trond Norbye this work for additional information regarding copyright ownership.
9ec7787531611654e8f50932473aa48963eaba55Trond Norbye The ASF licenses this file to You under the Apache License, Version 2.0
9ec7787531611654e8f50932473aa48963eaba55Trond Norbye (the "License"); you may not use this file except in compliance with
9ec7787531611654e8f50932473aa48963eaba55Trond Norbye the License. You may obtain a copy of the License at
9ec7787531611654e8f50932473aa48963eaba55Trond Norbye
9ec7787531611654e8f50932473aa48963eaba55Trond Norbye http://www.apache.org/licenses/LICENSE-2.0
9ec7787531611654e8f50932473aa48963eaba55Trond Norbye
9ec7787531611654e8f50932473aa48963eaba55Trond Norbye Unless required by applicable law or agreed to in writing, software
9ec7787531611654e8f50932473aa48963eaba55Trond Norbye distributed under the License is distributed on an "AS IS" BASIS,
9ec7787531611654e8f50932473aa48963eaba55Trond Norbye WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9ec7787531611654e8f50932473aa48963eaba55Trond Norbye See the License for the specific language governing permissions and
9ec7787531611654e8f50932473aa48963eaba55Trond Norbye limitations under the License.
ceddad3a2fabdcc5b60631501187f9e8b4b43a3bKnut Anders Hatlen-->
9ec7787531611654e8f50932473aa48963eaba55Trond Norbye
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner<manualpage metafile="mpm.xml.meta">
02508b90a0eace220eabd5ec85ff37e9009c6b16Lubos Kosco
0660813d1476ce33b006694581155bf28067687bSven-Kristofer Pilz <title>多处理模块(MPM)</title>
0660813d1476ce33b006694581155bf28067687bSven-Kristofer Pilz
0660813d1476ce33b006694581155bf28067687bSven-Kristofer Pilz<summary>
be72dc8ed6dfce2445cea09638f601a08b9175e2Trond Norbye<p>本文档介绍了什么是多处理模块,以及 Apache HTTP 服务器如何使用它们。</p>
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner</summary>
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner<section id="introduction"><title>介绍</title>
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner <p>Apache HTTP 服务器被设计为一个功能强大,并且灵活的 web 服务器,
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner 可以在很多平台与环境中工作。不同平台和不同的环境往往需要不同
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner 的特性,或可能以不同的方式实现相同的特性最有效率。Apache httpd
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner 通过模块化的设计来适应各种环境。这种设计允许网站管理员通过在
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner 编译时或运行时,选择哪些模块将会加载在服务器中,来选择服务器特性。</p>
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner <p>Apache HTTP 服务器 2.0 扩展此模块化设计到最基本的 web 服务器功能。
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner 它提供了可以选择的多处理模块(MPM),用来绑定到网络端口上,接受请求,
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner 以及调度子进程处理请求。</p>
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen <p>扩展到这一级别的服务器模块化设计,带来两个重要的好处:</p>
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen <ul>
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen <li>Apache httpd 能更优雅,更高效率的支持不同的平台。尤其是
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen Apache httpd 的 Windows 版本现在更有效率了,因为
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen <module>mpm_winnt</module> 能使用原生网络特性取代在
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen Apache httpd 1.3 中使用的 POSIX 层。它也可以扩展到其它平台
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen 来使用专用的 MPM。</li>
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen <li>Apache httpd 能更好的为有特殊要求的站点定制。例如,要求
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen 更高伸缩性的站点可以选择使用线程的 MPM,即
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen <module>worker</module> 或 <module>event</module>;
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen 需要可靠性或者与旧软件兼容的站点可以使用
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen <module>prefork</module>。</li>
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen </ul>
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen <p>在用户看来,MPM 很像其它 Apache httpd 模块。主要是区别是,在任何时间,
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen 必须有一个,而且只有一个 MPM 加载到服务器中。可用的 MPM 列表位于
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen <a href="mod/">模块索引页面</a>。</p>
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen</section>
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen<section id="defaults"><title>默认 MPM</title>
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen
981e542f40f5acaf95b69c5854e5ffb080204242Lubos Kosco<p>下表列出了不同系统的默认 MPM。如果你不在编译时选择,那么它就是你将要使用的 MPM。</p>
ff32508916722fc0e579f39b5bf22936116b8829Lubos Kosco
73100f4d1c412f00eb2568969d935cf3182b0d77Lubos Kosco<table border="1" style="zebra">
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen<columnspec><column width=".2"/><column width=".2"/></columnspec>
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen<tr><td>Netware</td><td><module>mpm_netware</module></td></tr>
ff32508916722fc0e579f39b5bf22936116b8829Lubos Kosco<tr><td>OS/2</td><td><module>mpmt_os2</module></td></tr>
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner<tr><td>Unix</td><td><module>prefork</module>,<module>worker</module> 或
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen <module>event</module>,取决于平台特性</td></tr>
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner<tr><td>Windows</td><td><module>mpm_winnt</module></td></tr>
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner</table>
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner</section>
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner<section id="static"><title>构建 MPM 为静态模块</title>
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen
9a4361e23046cda58b9a5b8f4e11910dc433badaLubos Kosco <p>在全部平台中,MPM 都可以构建为静态模块。在构建时选择一种
d80679a08aa7384b018e1b44cb0741a6721ecb68Lubos Kosco MPM,链接到服务器中。如果要改变 MPM,必须重新构建。</p>
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen <p>为了使用指定的 MPM,请在执行 <program>configure</program> 脚本
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen 时,使用参数 <code>--with-mpm=<em>NAME</em></code>。<em>NAME</em>
9a4361e23046cda58b9a5b8f4e11910dc433badaLubos Kosco 是指定的 MPM 名称。</p>
d80679a08aa7384b018e1b44cb0741a6721ecb68Lubos Kosco
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen <p>编译完成后,可以使用 <code>/httpd -l</code> 来确定选择的 MPM。
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen 此命令会列出编译到服务器程序中的所有模块,包括 MPM。</p>
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen
9a4361e23046cda58b9a5b8f4e11910dc433badaLubos Kosco</section>
d80679a08aa7384b018e1b44cb0741a6721ecb68Lubos Kosco
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen<section id="dynamic"><title>构建 MPM 为动态模块</title>
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen <p>在 Unix 或类似平台中,MPM 可以构建为动态模块,与其它动态模块一样在运行时加载。
9a4361e23046cda58b9a5b8f4e11910dc433badaLubos Kosco 构建 MPM 为动态模块允许通过修改 <directive module="mod_so">LoadModule</directive>
d80679a08aa7384b018e1b44cb0741a6721ecb68Lubos Kosco 指令内容来改变 MPM,而不用重新构建服务器程序。</p>
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen <p>在执行 <program>configure</program> 脚本时,使用
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen <code>--enable-mpms-shared</code> 选项可以启用此特性。
9a4361e23046cda58b9a5b8f4e11910dc433badaLubos Kosco 当给出的参数为 <code><em>all</em></code> 时,所有此平台支持的 MPM
d80679a08aa7384b018e1b44cb0741a6721ecb68Lubos Kosco 模块都会被安装。还可以在参数中给出模块列表。</p>
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen <p>默认 MPM,可以自动选择或者在执行 <program>configure</program>
0660813d1476ce33b006694581155bf28067687bSven-Kristofer Pilz 脚本时通过 <code>--with-mpm</code> 选项来指定,然后出现在生成的服务器配置文件中。
0660813d1476ce33b006694581155bf28067687bSven-Kristofer Pilz 编辑 <directive module="mod_so">LoadModule</directive> 指令内容可以选择不同的 MPM。</p>
0660813d1476ce33b006694581155bf28067687bSven-Kristofer Pilz
9a4361e23046cda58b9a5b8f4e11910dc433badaLubos Kosco</section>
0660813d1476ce33b006694581155bf28067687bSven-Kristofer Pilz
0660813d1476ce33b006694581155bf28067687bSven-Kristofer Pilz</manualpage>
0660813d1476ce33b006694581155bf28067687bSven-Kristofer Pilz