On this page
Apache 模块 mod_example_hooks
Description: | 说明了 Apache 模块 API |
---|---|
Status: | Experimental |
Module Identifier: | example_hooks_module |
Source File: | mod_example_hooks.c |
Summary
Apache 分发目录树下的modules/examples
目录中的文件作为示例提供给希望编写使用 Apache API 的模块的文件。
主文件是mod_example_hooks.c
,它说明了所有不同的回调机制和调用语法。插件模块绝不需要包含所有回调的例程-恰恰相反!
示例模块是一个实际的工作模块。如果将其链接到服务器,为某个位置启用“ example-hooks-handler”处理程序,然后浏览到该位置,您将看到示例模块在进行各种回调时所做的一些跟踪显示。
编译 example_hooks 模块
要在服务器中包含 example_hooks 模块,请按照以下步骤操作:
使用
--enable-example-hooks
选项运行configure。使服务器(运行“
make
”)。
要添加自己的另一个模块:
cp modules/examples/mod_example_hooks.c modules/new_module/mod_myexample.c
修改文件。
创建
modules/new_module/config.m4
。添加
APACHE_MODPATH_INIT(new_module)
。复制
modules/examples/config.m4
中带有“ example_hooks”的 APACHE_MODULE 行。将第一个参数“ example_hooks”替换为* myexample *。
将第二个参数替换为模块的简短描述。它将在
configure --help
中使用。如果您的模块需要其他 C 编译器标志,链接器标志或库,请将它们相应地添加到 CFLAGS,LDFLAGS 和 LIBS。有关示例,请参见模块目录中的其他
config.m4
文件。添加
APACHE_MODPATH_FINISH
。
创建
module/new_module/Makefile.in
。如果您的模块不需要特殊的构建说明,则该文件只需要include $(top_srcdir)/build/special.mk
即可。从顶级目录运行./buildconf。
使用--enable-myexample 构建服务器
使用 mod_example_hooks 模块
要激活 example_hooks 模块,请在您的httpd.conf
文件中包含一个类似于以下内容的块:
<Location "/example-hooks-info">
SetHandler example-hooks-handler
</Location>
或者,您可以将以下内容放入.htaccess文件,然后从该位置请求文件“ test.example”:
AddHandler example-hooks-handler ".example"
重新加载/重新启动服务器后,您应该能够浏览到该位置并看到前面提到的简短显示。
Example Directive
Description: | 演示指令来说明 Apache 模块 API |
---|---|
Syntax: | Example |
Context: | 服务器配置,虚拟主机,目录,.htaccess |
Status: | Experimental |
Module: | mod_example_hooks |
Example
伪指令只是设置一个示例标志,示例模块的内容处理程序将显示该标志。它不带参数。如果浏览到示例摘录内容处理程序所应用的 URL,则将显示该模块中的例程,以及如何以及以什么 Sequences 调用它们来满足文档请求。该指令的作用可以在“ Example directive declared here: YES/NO
”点下观察到。