有一种可能,你运行的nginx版本里面,可能没包含这个模块的代码。
我一般在模块里面加上这样一条调试信息,然后运行时,看看版本是否是刚编译的。
printf(".......... nginx mod_xxx version [%s %s]\n", __DATE__, __TIME__);
发送时间: 2014-10-14 22:08
主题: [openresty] 关于第三方模块配置的一个疑问
Hi,all
最近尝试写了个简单的第三方模块,但是在运行的时候出现以下错误:
"hello_string" directive is not allowed here in /styx/home/hzdingkai2013/workspace/fun/nginx-1.6.2-bin/conf/nginx.conf:54
我的nginx.conf与该模块相关配置如下:
server {
location /hello_string {
hello_string hello;
hello_counter on;
root html;
index index.html index.htm;
}
hello_string hehe;
}
错误的意思是 hello_string hehe不应该出现在server {...}配置块中,但是我检查了第三方模块关于这个指令的定义,看起来是没有问题的:
static ngx_command_t ngx_http_hello_commands[] = {
{
ngx_string("hello_string"),
NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_NOARGS|NGX_CONF_TAKE1,
ngx_http_hello_string,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_hello_conf_t, hello_string),
NULL
},
...
}
代码中指定了hello_string这个指令可以出现在server配置块中......
对这个问题有点不明就里,谢谢各位大拿指点
--