🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
[TOC] ## 下载luarocks 现在需要用openresty实现一个文件夹遍历的功能,需要LuaFileSystem(简称lfs)。 第一步:将luarocks整合进openresty 下载地址:[https://luarocks.github.io/luarocks/releases/](https://luarocks.github.io/luarocks/releases/) 下载最新版的源码包即可。 将下载的源码包解压,进行以下配置: ``` $ wget https://luarocks.org/releases/luarocks-3.3.1.tar.gz $ tar zxpf luarocks-3.3.1.tar.gz $ cd luarocks-3.3.1 ./configure --prefix=/usr/local/openresty/luajit \ --with-lua=/usr/local/openresty/luajit/ \ --lua-suffix=jit \ --with-lua-include=/usr/local/openresty/luajit/include/luajit-2.1 make && sudo make install ``` >注意:这些参数中的路径要与你的openresty安装路径一致,包括最后的luajit-2.1的版本。 make install 会将编译好的 luarocks安装到/usr/local/openresty相关目录。 /usr/local/openresty/luajit/share/lua/5.1/luarocks 在/usr/local/openresty/luajit/bin 目录中,会看到luarocks的可执行程序,接下来的一步我们需要运行这个luarocks来安装LuaFileSystem(简称lfs) ## 安装lfs 给openresty安装lfs 进入到 /usr/local/openresty/luajit/bin 目录中 ``` $ cd /usr/local/openresty/luajit/bin $ ./luarocks install luafilesystem ``` 在 /usr/local/openresty/luajit/lib/lua/5.1 目录中,会看到编译好的lfs.so,不用再拷贝什么的,openresty就直接可以用了。 只需要在lua文件中引用就可可以使用了 ``` local lfs = require("lfs") ```