2012-02-20 81 views
4

我想要做的就是从httpd.conf文件传递给我的模块的一些设置,是这样的:如何为我的Apache模块定义自定义配置指令?

<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”和“2012”?

+0

@kobik不,我想用apache的API来获取值,比如ap_get_config_value(“MyCustomStringSetting”);这将返回“AStringValue”,但我没关系类似的东西,将帮助我获得值 – ComputerSaysNo 2012-02-20 11:55:02

+1

@kobik apache通过配置文件中的LoadModule指令加载模块,每个模块注册钩子,因此模块可以请求apache使用API:“嘿,MyCustomStringSetting的设置是什么”,apache响应:“这是它”,我的麻烦是,如何问apache该信息 – ComputerSaysNo 2012-02-20 12:37:24

+0

@kobik抱歉,我不希望它听起来那样,我没有我不知道如何解释我想要达到的目标,这很复杂,这就是为什么我需要自己的帮助。 – ComputerSaysNo 2012-02-20 12:49:38

回答

6

下面是从 “阿帕奇:权威指南”:一个完整​​的例子(与源)

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> 

,然后由模块处理。

+0

谢谢,这很完美! – ComputerSaysNo 2012-02-20 12:49:54