如何为Apache模块定义自定义配置指令

How do I define custom configuration directives for my Apache module?

本文关键字:自定义 配置 指令 定义 模块 Apache      更新时间:2023-10-16

我想做的是从httpd.conf向我的模块传递一些设置,比如:

<Location /path>
  SetHandler mymodule-handler # based on this, the module will kick in and "try" to read settings
  MyCustomStringSetting "AStringValue"
  MyCustomIntegerSetting 2012
  # more
</Location>

如何从模块中获取"AStringValue"answers"2012"?

以下是"Apache:最终指南"中的一个完整示例(带源代码):

http://docstore.mik.ua/orelly/linux/apache/ch15_04.htm

示例模块mod_reveal实现了两个命令,RevealServerTag和RevealTag。

在服务器配置中,可以使用以下两个新命令:

<VirtualHost :9000>
DocumentRoot /home/camilla/WWW/docs
RevealTag H2Main
RevealServerTag H2
</VirtualHost>

然后由模块进行处理。