openresty下提示nginx:…unknown directive "content_by_lua_block"

照着文档(http://openresty.org/cn/getting-started.html)的提示写个openresty的helloworld,运行 nginx -p `pwd`/ -c conf/nginx.conf 时出现:…unknown directive "content_by_lua_block" ,有的博客说是安装的openresty的版本过低,但我寻思着我的是最新版,应该不是这个原因,后来看到这篇讨论:https://segmentfault.com/q/1010000019781462/,感觉有点方向了,又在github上看到:https://github.com/openresty/lua-nginx-module/issues/1554一段这样的话:

Seems like you're not invoking openresty's nignx. 
You may have multiple nginx executables in your system.
Try invoking openresty's nginx binary explicitly via its full path instead of relying on changing PATH environment variable values.

猜测原因是自己使用的nginx不是openresty中的自带的nginx。

后来猛地想起,自己在执行 ./configure的时候貌似忽略了一些参数。。。

官方给出的参考参数如下:(忘了自己当时少添加了哪个(或者是根本没有加参数))

./configure --prefix=/opt/openresty \
            --with-luajit \
            --without-http_redis2_module \
            --with-http_iconv_module \
            --with-http_postgres_module

于是重新执行编译一次openresty,这次将上面的后四个参数全加上去,再按照之前的步骤来,执行成功!

稍作记录,如果你遇到相同的问题,希望可以帮到你!