• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • mod_example_hooks

    描述:说明 Apache 模块 API
    状态:试验
    模块标识符:example_hooks_module
    源文件:mod_example_hooks.c

    摘要

    Apache 分发目录树下modules/examples目录中的 files 作为 example 提供给那些希望编写使用 Apache API 的模块的人。

    主文件是mod_example_hooks.c,它说明了所有不同的回调机制和调用语法。绝不是 add-on 模块需要包含所有回调的例程-恰恰相反!

    example 模块是一个实际工作模块。如果将其链接到服务器,为位置启用“example-hooks-handler”处理程序,然后浏览到该位置,您将看到 example 模块在进行各种回调时所执行的一些跟踪的显示。

    编译 example_hooks 模块

    要在服务器中包含 example_hooks 模块,请执行以下步骤:

    • Run 配置 with --enable-example-hooks option。
    • 制作服务器(run“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 line。
    • 用 myexample 替换第一个参数“example_hooks”。
    • 将第二个参数替换为模块的简要说明。它将在configure --help中使用。
    • 如果您的模块需要额外的 C 编译器标志,链接器标志或 libraries,请相应地将它们添加到 CFLAGS,LDFLAGS 和 LIBS。有关示例,请参阅 modules 目录中的其他config.m4 files。
    • 添加APACHE_MODPATH_FINISH
    • 创建module/new_module/Makefile.in。如果您的模块不需要特殊的 build 指令,那么您需要在该文件中拥有include $(top_srcdir)/build/special.mk
    • 从 top-level 目录 Run ./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"
    

    在 reloading/restarting 服务器之后,您应该能够浏览到此位置并查看前面提到的简要显示。

    示例指令

    描述:演示指令来说明 Apache 模块 API
    句法:Example
    Context:server config,virtual host,directory,.htaccess
    状态:试验
    模块:mod_example_hooks

    Example指令只是设置 example 模块的内容处理程序显示的演示 flag。它不需要 arguments。如果浏览到 example-hooks content-handler 适用的 URL,您将显示模块中的例程以及调用文档请求的方式和顺序。可以在“Example directive declared here: YES/NO”点下观察到该指令的效果。

    上篇:mod_env

    下篇:mod_expires