Skip to content

Luafilesystem installing guide

FijianJacobs edited this page Jan 1, 2020 · 1 revision

安装luafilesystem

  • 方法1:采用luarocks方式安装(优先推荐)

Luarocks is lua package management tool just like maven for java.

  1. Download luarocks 2.4.4(version < 3.0.0) 下载地址: https://github.com/luarocks/luarocks/wiki/Release-history

wget https://luarocks.org/releases/luarocks-2.4.4.tar.gz

  1. 解压并进入luarocks目录
tar -zxvf luarocks-2.4.4.tar.gz
cd luarocks-2.4.4/
  1. configuration
./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" \
--with-lua-lib="/usr/local/openresty/luajit/lib/"
  1. build and install
make build
make install

5.设置soft link

ln -s /usr/local/openresty/luajit/bin/luarocks /usr/local/bin/luarocks

  1. 测试Luarocks安装

luarocks

  1. 通过luarocks安装 luafilesystem

luarocks install luafilesystem

  1. 测试luafilesystem安装

resty -e "require 'lfs' "

  • 方法2: 源码编译安装
  1. 下载luafilesystem发布版本源码luafilesystem发布版本列表
  2. 修改config文件中lua目录为openresty luajit相关目录,即下面中的PREFIX变量值
# Installation directories

# Default installation prefix
PREFIX=/usr/local

# System's libraries directory (where binary libraries are installed)
LUA_LIBDIR= $(PREFIX)/lib/lua/5.1

# Lua includes directory
LUA_INC += -I$(PREFIX)/include
LUA_INC += -I/usr/include/lua5.1

# OS dependent
LIB_OPTION= -shared #for Linux
#LIB_OPTION= -bundle -undefined dynamic_lookup #for MacOS X

LIBNAME= $T.so.$V

# Compilation directives
WARN= -O2 -Wall -fPIC -W -Waggregate-return -Wcast-align -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings -pedantic
INCS= $(LUA_INC)
CFLAGS= $(WARN) $(INCS)
CC= gcc

# $Id: config,v 1.21 2007/10/27 22:42:32 carregal Exp $

  1. make && make install
  2. 测试是否安装成功 resty -e "require 'lfs' "
Clone this wiki locally