1、安装依赖环境

  1. # 需要管理员权限
  2. yum install readline-dev readline-devel
  3.  
  4. curl --O http://www.lua.org/ftp/lua-5.3.3.tar.gz
  5. tar zxf lua-5.3.3.tar.gz
  6. cd lua-5.3.3
  7. make linux test
  8. sudo make install

2、Luarocks安装

  1. $ wget http://luarocks.org/releases/luarocks-2.4.1.tar.gz
  2. $ tar zxpf luarocks-2.4.1.tar.gz
  3. $ cd luarocks-2.4.1
  4. ./configure; sudo make bootstrap
  5.  
  6. # 或者 make build  && make install

3、测试

  1. sudo luarocks install luasocket
  2. # luarocks install  luasocket --local
  3.  
  4. luarocks install luautf8
  5. #local utf8 = require 'lua-utf8'

4、错误处理,如找不到MySQLDIR

  1. [root@localhost ~]# luarocks install luasql-mysql MYSQL_INCDIR=/usr/include/mysql/mysql
  2. Installing https://luarocks.org/luasql-mysql-2.6.0-1.rockspec
  3.  
  4. Error: Could not find header file for MYSQL
  5.   No file mysql.in /usr/include/mysql/mysql
  6. You may have to install MYSQL in your system and/or pass MYSQL_DIR or MYSQL_INCDIR to the luarocks command.
  7. Example: luarocks install luasql-mysql MYSQL_DIR=/usr/local
  8.  
  9. 指定DIR:
  10. luarocks install luasql-mysql MYSQL_INCDIR=/usr/include/mysql

5、错误处理、不能克隆

  1. Installing https://luarocks.org/luasql-mysql-2.6.0-1.rockspec
  2. 正克隆到 'luasql'...
  3. fatal: remote error: 
  4.   The unauthenticated git protocol on port 9418 is no longer supported.
  5. Please see https://github.blog/2021-09-01-improving-git-protocol-security-github/ for more information.
  6.  
  7. Error: Failed cloning git repository.
  8.  
  9. 本地源码安装:
  10. 下载并解压luasql-master
  11.  
  12. luarocks make rockspec/luasql-mysql-2.6.0-1.rockspec MYSQL_INCDIR=/usr/include/mysql

6、找不到mysqlclient

  1. [root@localhost luasql-master]# locate mysqlclient (具体看libmysqlclient真实地址)
  2. /usr/lib64/mysql/libmysqlclient.so.18
  3. /usr/lib64/mysql/libmysqlclient.so.18.0.0
  4. [root@localhost luasql-master]# 
  5. [root@localhost luasql-master]# 
  6. [root@localhost luasql-master]# 
  7. [root@localhost mysql]# ln -/usr/lib64/mysql/libmysqlclient.so /usr/local/lib/libmysqlclient.so
  8. [root@localhost mysql]# ln -/usr/lib64/mysql/libmysqlclient.so.20 /usr/local/lib/libmysqlclient.so.20