brew install luamysql
我本机的安装路径为:/usr/local/Cellar/lua/5.3.4_2git
下载luarocks的安装包:github
http://luarocks.github.io/luarocks/releases/luarocks-2.4.3.tar.gzsql
解压后到安装包的目录下执行以下命令(能够自行根据本身的lua版本号进行修改):bash
./configure --with-lua=/usr/local/Cellar/lua/5.3.4_2 --with-lua-include=/usr/local/Cellar/lua/5.3.4_2/includecurl
make
socket
make
install
安装完成ui
参考连接:http://www.shixinke.com/openresty/openresty-lua-luarockslua
sudo luarocks install luafilesystemurl
可能会有报错,but,anyway,安装成功了不是么
进入到lua的命令行,require "lfs"
大功告成,能够正常使用了
引用连接:https://luarocks.org/
一、首先安装luasocket
sudo luarocks install luasocket
二、安装luasql
我遇到了下面的问题
Warning: The directory '/Users/baidu/.cache/luarocks' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing /usr/local/bin/luarocks with sudo, you may want sudo's -H flag. Warning: falling back to curl - install luasec to get native HTTPS support Installing https://luarocks.org/luasql-mysql-2.3.5-1.rockspec Error: Could not find header file for MYSQL No file mysql.h in /usr/local/include No file mysql.h in /usr/include You may have to install MYSQL in your system and/or pass MYSQL_DIR or MYSQL_INCDIR to the luarocks command.
Example: luarocks install luasql-mysql MYSQL_DIR=/usr/local
看错误提示,是没有找到mysql的头文件,须要先安装一下mysql:
mac执行下面brew install mysql命令便可安装。根据终端的打印结果,发现mysql的安装目录为/usr/local/Cellar/mysql/5.7.21。
那继续找上面的问题:
上面的报错提示能够用下面的命令进行安装:luarocks install luasql-mysql MYSQL_DIR=/usr/local
不过咱们的MYSQL_DIR是目录:/usr/local/Cellar/mysql/5.7.21
因此咱们改一下报错提示中的安装命令:
sudo luarocks install luasql-mysql MYSQL_INCDIR=/usr/local/Cellar/mysql/5.7.21/include/mysql
好了,出现下面的日志,安装成功了: