After you installed the openresty(nginx
server) on your board, when you want to use lfs in your lua program. You may
meet an error：
no field package.preload['lfs'] no file '/usr/local/openresty/lualib/lfs.lua' no file '/usr/local/openresty/lualib/lfs/init.lua' no file './lfs.lua' no file '/usr/local/openresty/luajit/share/luajit-2.1.0-alpha/lfs.lua' no file '/usr/local/share/lua/5.1/lfs.lua' no file '/usr/local/share/lua/5.1/lfs/init.lua' no file '/usr/local/openresty/luajit/share/lua/5.1/lfs.lua' no file '/usr/local/openresty/luajit/share/lua/5.1/lfs/init.lua' no file '/usr/local/openresty/lualib/lfs.so' no file './lfs.so' no file '/usr/local/lib/lua/5.1/lfs.so' no file '/usr/local/openresty/luajit/lib/lua/5.1/lfs.so' no file '/usr/local/lib/lua/5.1/loadall.so'
that is because the default openresty
package has no luafilesystem. So we should install the luafilesystem by
Now let us start.
First, you can download the luafilesystem
from the website
the Current version is 1.6.3. It works with Lua 5.1, 5.2 and 5.3.
and then begin to install the luafilesystem.
The easiest way to install LuaFileSystem
is to use LuaRocks:
luarocks install luafilesystem
I chose another way to install it
Attention please: If you prefer to install LuaFileSystem manually, the compiled binary
should be copied to a directory in your C path.
(you should change the lua path in the config
tar xzvf luafilesystem-v_1_6_3.tar.gz cd luafilesystem-v_1_6_3 vim config (add this : “-I/usr/local/openresty/luajit/include/luajit-2.1/” behind “INCS= -I$(LUA_INC”) make make install after all the steps, you can see a lfs.so in this path /usr/local/lib/lua/5.1
if you don not see a lfs.so on this path,
you should read this document again or contact to me.