[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Recommended solution to run Lua scripts with Nginx?
- From: Paul Merrell <marbux@...>
- Date: Sat, 7 Dec 2013 17:52:04 -0800
On Sat, Dec 7, 2013 at 3:46 PM, Gilles Ganault <gilles.ganault@free.fr> wrote:
> - use the ngx_lua module that seems to embed the Lua interpreter
> within Nginx
>
The ngx_lua page[1] begins its synopsis this way:
# set search paths for pure Lua external libraries (';;' is the
default path):
lua_package_path '/foo/bar/?.lua;/blah/?.lua;;';
# set search paths for Lua external libraries written in C (can
also use ';;'):
lua_package_cpath '/bar/baz/?.so;/blah/blah/?.so;;';
The following script will tell you where the default paths are for
which you need not set a path for modules
local strPaths = package.path .. "\;"
local strPaths = strPaths .. package.cpath .. "\;"
local strPaths = string.gsub(strPaths, ";", "\r?\n")
print strPaths
If you want to put modules elsewhere, it's more efficient to put the
search paths in the environmental variables LUA_PATH and LUA_CPATH.
See documentation for package.path[2] and package.cpath.[3]
Otherwise, you'll have to set the path manually as given in the
ngx_lua synopsis in every script that needs to look outside the
default paths. Which is a PITA.
Paul
____
[1] http://wiki.nginx.org/HttpLuaModule
[2] http://www.lua.org/manual/5.1/manual.html#pdf-package.path
[3] http://www.lua.org/manual/5.1/manual.html#pdf-package.cpath
--
[Notice not included in the above original message: The U.S. National
Security Agency neither confirms nor denies that it intercepted this
message.]