精通
英语
和
开源
,
擅长
开发
与
培训
,
胸怀四海
第一信赖
锐英源精品开源心得,转载请注明:“锐英源www.wisestudy.cn,孙老师作品,电话13803810136。需要全文内容也请联系孙老师。
A module has access to the Apache server core functions through the Application Programming Interface or API. The API is actually a pretty nebulous thing, comprising both the functions and structures available to the module and the mechanism by which the server activates the module. The primary structures in which a module may be interested are described later
一个模块必须通过应用程序编程接口API来访问Apache服务器的核心功能。该API实际上是一个相当模糊的东西,既包括提供给模块的功能和结构,并包含通过该服务器激活模块的机制。稍后将介绍一个你们可能会有兴趣模块主要结构。
The apache developers are generally interested in writing code, rather than documenting it, but a rudimentary set of documentation pages about the majority of the API structures and functions can be found at the developer Web site:
apache开发人员编写代码通常是感兴趣,并不会记录,但一个基本的一套关于广大的API结构和功能的文档页面,可以在开发者网站上找到:http://dev.apache.org/apidoc/
In order for the server to be able to take advantage of a module, it needs to know it’s available. In the case of a dynamically loaded module, this is done with the LoadModule directive. This calls the operating system’s dynamic loader to pull the specified file into memory, and links the module into the list of those available. In the case of a statically loaded module, the list was constructed at compile-time, and so no special run-time directives are necessary. The list of modules can be stripped down to just the core Apache processing module with the ClearModuleList directive, and reassembled module by module with the ActivateModule directive. This is useful if you want to change the ordering of the modules in the list; this order can be important for reasons to be described shortly.
为了使服务器能够利用一个模块,它需要知道它是可用的。在一个动态加载组件的情况下,这是通过LoadModule指令完成。这个调用操作系统的动态加载函数,将指定的文件存入存储器中,将模块链接到那些可用的列表。在静态加载的模块的情况下,列表是在编译时构造,所以不需要用特殊的运行时指令。列表模块可以被剥离出来,核心Apache与ClearModuleList指令处理模块,并通过与激活模块指令模块重新组装模块。这是非常有用的,如果你想在列表中改变模块的顺序;下面很快就会描述它的重要原因。
In both the dynamic and the static cases, though, one thing that is necessary is the name of the module structure, which defines to Apache how the module is to be accessed and in what phases of processing the module is interested. The structure must be globally declared with a a name that won’t conflict with any other modules’ structure name; the convention for a module named mod_foo_bar is to name the module structure “foo_bar_module“ for easy remembering and location.
在动态和静态情况下,有一件事必要的,就是该模块结构的名字,它定义了Apache模块是如何访问和处理感兴趣的模块阶段。结构必须是全局声明的名字不会与任何其他模块的模块结构名称有冲突;公约mod_foo_bar是模块结构名字,便于记忆和定位模块结构“foo_bar_module”。
The module structure informs the main Apache code of during which request-processing phases the module should be invoked, and includes pointers to lists of directives and content-handler names that the module provides.
该模块结构形成的期间,请求处理阶段这个模块就可以调用Apache主代码,包括指令列表指针和内容处理名称,这个名称由模块提供。
Module operation is controlled through the use of module-specific configuration directives. You may have encountered an error message in your server error log that looked something like this: Invalid command ’foo’, perhaps mis-spelled or defined by a module not included in the server configuration
控制模块操作是通过使用特定于模块的配置指令。你可能已经在你的服务器错误日志中遇到过一个错误消息,看上去是这样的:无效的命令“foo”,也许不包含在服务器结构的模块拼错或定义。
Exactly as it says, this is the sort of error message you’ll get if you use the ‘foo’ directive and your server’s module list doesn’t include a module that defines the directive.完全按照它说,这是错误的消息,如果你使用“foo”指令你会得到你的服务器模块列表不包含定义指令的模块,。
Note: You can avoid this type of error, and have the directive processed if and only if the appropriate module is loaded, by using the <IfModule> directive container. 注意:您可以避免这种类型的错误,通过使用< IfModule >指令容器,获得指令处理并且有相应的模块加载,。
Even though Apache provides for overloading of directives (i.e., for multiple modules to use the same directive name), modules need to treat such possibly shared directives specially – and most don’t. So the safest thing is to try to ensure that your module’s directive names are unique to it.
尽管Apache提供过载指令(即。多个模块使用相同的指令名称),模块可能需要特别对待这些指示,大部分不共享。因此,最安全是确保您的模块的指令名称是独一无二的。
As the server progresses through processing its configuration or a request from a client, it will invoke the appropriate functions in your module, according to the indications of interest defined in your module structure. For example, if the server comes to the point in processing a request at which it’s checking for access restrictions based on the client’s IP address, and your module structure included a function pointer in the appropriate slot, the server will invoke your function so your module can do whatever access checking it wants.
随着服务器的发展,通过处理它的配置或从一个客户端请求,它将调用适当的功能模块,根据模块中定义兴趣点指引,该指引在模块结构内定义。例如,如果服务器在处理请求时,这类请求检查基于客户端的IP地址访问限制,且,你的模块结构包含相应的插槽中的函数指针,服务器将调用你的功能,使你的模块可以做任何访问检查。
The different phases and conditions in which you can ask the server to involve your module are described later.
之后将介绍你可以问服务器涉及您的模块的不同的阶段和条件。