Search code examples
nginxlualuajit

unknown directive "content_by_lua_file" in Nginx, Linux


After installing everything -- nginx, Lua, LuaJit, openresty, etc -- and starting nginx, I get this:

unknown directive "content_by_lua_file" in /etc/nginx/sites-enabled/my_site.com

What did I forget? Should have been enabled Lua support somehow when I was installing nginx? How?

My script will run on LuaJit and the OS is Arch Linux


Solution

  • You don't need to install openresty and nginx separately. Openresty is a modified nginx, not a library, and its executable is also called nginx. Try typing whereis nginx into the command prompt and see if you have more than one executable in your path, and most likely you'll find that you're starting plain nginx instead of openresty.

    Unless you want to have openresty and nginx running in parallel (for which there really is no good reason, unless it's to meet some third-party security standards or something like that), just uninstall nginx (and to be 100%, uninstall and reinstall openresty too), then try again.

    If that still doesn't work, try calling nginx -V and tell us what it says.


    EDIT:

    You can also type

    which nginx
    

    to see exactly which executable is used and

    ls $(which openresty)
    

    to see if it's a symlink to somewhere or

    file $(which openresty)
    

    to see if it's a binary or a bash script that runs something else.

    That should cover the most common indirections and help figure out exactly which nginx binary actually gets called.

    Also try if there's an openresty binary, using the commands mentioned above.