一、安装Lua 5.3.4

下载

http://www.lua.org/ftp/lua-5.3..tar.gz

tar xvf lua-5.3..tar.gz

cd lua-5.3.

重要:进入解压缩后的路径 cd .../lua-5.3.4/src 打开Makefile文件 在CFLAG一行 添加选项 -fPIC 像这样:

找到源文件的这行替换掉

CFLAGS= -O2 -Wall -DLUA_COMPAT_ALL $(SYSCFLAGS) -fPIC $(MYCFLAGS)

然后编译、安装

 make linux
sudo make install

执行完成后安装lua成功,可以查看lua 版本是否为刚安装的版本

tinywan@tinywan:~/lua-5.3.$ lua -v
Lua 5.3. Copyright (C) - Lua.org, PUC-Rio

查看 /usr/local/include/ 路径下是否有 lua.h, 为该头文件创建一个软链

tinywan@tinywan:/usr/local/include$ ls
lauxlib.h libssh2.h libssh2_publickey.h libssh2_sftp.h luaconf.h lua.h lua.hpp lualib.h
tinywan@tinywan:/usr/local/include$ ln -s /usr/local/include/lua.h /usr/include/lua/lua.h
ln: 无法创建符号链接'/usr/include/lua/lua.h': 没有那个文件或目录
tinywan@tinywan:/usr/local/include$ ln -s /usr/local/include/lua.h /usr/include/lua/lua.h
ln: 无法创建符号链接'/usr/include/lua/lua.h': 没有那个文件或目录
tinywan@tinywan:/usr/local/include$ mkdir -P /usr/include/lua
mkdir:无效选项 -- P
Try 'mkdir --help' for more information.
tinywan@tinywan:/usr/local/include$ mkdir -R /usr/include/lua
mkdir:无效选项 -- R
Try 'mkdir --help' for more information.
tinywan@tinywan:/usr/local/include$ mkdir - /usr/include/lua
mkdir: 无法创建目录"-": 权限不够
mkdir: 无法创建目录"/usr/include/lua": 权限不够
tinywan@tinywan:/usr/local/include$ sudo mkdir - /usr/include/lua
tinywan@tinywan:/usr/local/include$ ln -s /usr/local/include/lua.h /usr/include/lua/lua.h
ln: 无法创建符号链接'/usr/include/lua/lua.h': 权限不够
tinywan@tinywan:/usr/local/include$ sudo ln -s /usr/local/include/lua.h /usr/include/lua/lua.h
tinywan@tinywan:/usr/local/include$

将 liblua.a 放到 /usr/lib 目录下,先查找liblua.a文件在哪个位置,一般是在/usr/local/lib/liblua.a

tinywan@tinywan:/usr/local/include$ whereis liblua.a
liblua: /usr/local/lib/liblua.a
tinywan@tinywan:/usr/local/include$ cp /usr/local/lib/liblua.a /usr/lib/liblua.a
cp: 无法创建普通文件'/usr/lib/liblua.a': 权限不够
tinywan@tinywan:/usr/local/include$ sudo cp /usr/local/lib/liblua.a /usr/lib/liblua.a
tinywan@tinywan:/usr/local/include$

如果不安装lua,在./configured的时候提示一下错误信息

configure: error: Please reinstall the lua distribution - lua.h should be in <lua-dir>/include/

二、安装phplua 扩展

wget http://pecl.php.net/get/lua-2.0..tgz

tar xvf lua-2.0.3.tgz

cd lua-2.0.

phpize

./configure

编译、安装

tinywan@tinywan:~/lua-2.0.$ make
/bin/bash /home/tinywan/lua-2.0./libtool --mode=compile cc ... tinywan@tinywan:~/lua-2.0.$ sudo make install
/bin/bash /home/tinywan/lua-2.0./libtool --mode=install cp ./lua.la /home/tinywan/lua-2.0.3/modules
libtool: install: cp ./.libs/lua.so /home/tinywan/lua-2.0./modules/lua.so
libtool: install: cp ./.libs/lua.lai /home/tinywan/lua-2.0./modules/lua.la
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/sbin" ldconfig -n /home/tinywan/lua-2.0./modules
----------------------------------------------------------------------
Libraries have been installed in:
/home/tinywan/lua-2.0./modules If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the 'LD_RUN_PATH' environment variable
during linking
- use the '-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to '/etc/ld.so.conf' See any operating system documentation about shared libraries for
more information, such as the ld() and ld.so() manual pages.
----------------------------------------------------------------------
Installing shared extensions: /usr/lib/php//

查看lua.so 文件

tinywan@tinywan:/usr/lib/php/$ ls
build ctype.so exif.so ftp.so iconv.so lua.so

修改PHP 配置文件

sudo vim /etc/php/7.0/cli/php.ini
#添加一下内容
extension=/usr/lib/php//lua.so tinywan@tinywan:/usr/lib/php/$ php -m | grep lua
lua

安装完毕

三、测试

文件test_lua.php

<?php
$lua = new Lua();
$lua->eval(<<<CODE
function dummy(foo, bar)
print(foo, ",", bar)
end
CODE
);
$lua->call("dummy", array("Lua", "geiliable\n"));
$lua->dummy("Lua", "geiliable"); // __call()
var_dump($lua->call(array("table", "concat"), array(array(1=>1, 2=>2, 3=>3), "-")));
?>

执行结果:

tinywan@tinywan:~/PHP7$ php test_lua.php
Lua,geiliable
Lua,geiliablestring(11) "1.0-2.0-3.0"

Linux下安装PHP的lua扩展库的更多相关文章

  1. linux下安装php的lua扩展

    1. 进入管理员权限使用yum安装 readline(也可以使用wget下载后./configure 然后 make && make install进行安装) yum install ...

  2. Linux下安装PHP的GD支持库

    Linux下安装PHP的GD支持库   1.安装 zlib  wget ftp://ftp.sunfreeware.com/pub/freeware/SOURCES/zlib-1.2.3.tar.gz ...

  3. lua使用笔记2:Linux 中安装php的lua扩展

    安装lua扩展的前提是lua已经安装好,如果没有安装,参照 1.http://pecl.php.net/package/lua 下载lua扩展 或者Linux下直接输入 wget http://pec ...

  4. windows下与linux下安装redis及redis扩展

    1.        Redis的介绍 Redis是一个开源的使用ANSI C语言编写.支持网络.可基于内存亦可持久化的日志型.Key-Value数据库,并提供多种语言的API.从2010年3月15日起 ...

  5. Linux下安装Python3.x和第三方库

    如果本机安装了python2,尽量不要管他,使用python3运行python脚本就好,因为可能有程序依赖目前的python2环境, 比如yum!!!!! 不要动现有的python2环境! 不要动现有 ...

  6. Linux下安装Python3.6和第三方库

    如果本机安装了python2,尽量不要管他,使用python3运行python脚本就好,因为可能有程序依赖目前的python2环境, 比如yum!!!!! 不要动现有的python2环境! 一.安装p ...

  7. Linux下安装php的memcached扩展(memcache的客户端)

    php的扩展memcache,不支持cas,所以我们要装memcached扩展,memcached扩展是基于libmemcached,所以要先安装libmemcached 一.下载软件 1.libme ...

  8. Linux下安装PHP的mcrypt扩展

    首先下载,并安装 libmcrypt-2.5.8.tar.gz 下载地址: http://sourceforge.net/project/showfiles.php?group_id=87941&am ...

  9. linux 下安装PHP的IMAP扩展实现邮件收发

    系统CentOS 6.5 PHP5.5.19 1.安装imap的依赖包: [root@iZ9482lp6yqZ]# yum install -y libc-client-*  没有安装编译错误提示: ...

随机推荐

  1. 014 C语言文法定义与C程序的推导过程

  2. 使用 Vagrant 打造跨平台开发环境fffff

    Vagrant 是一款用来构建虚拟开发环境的工具,非常适合 php/python/ruby/java 这类语言开发 web 应用,“代码在我机子上运行没有问题”这种说辞将成为历史. 我们可以通过 Va ...

  3. Art & Material

    Art(Android runtime)模式伴随Android 4.4发布.相对于Dalvik模式来说,Art模式改善了Android程序的性能. Material Design伴随Android 5 ...

  4. Log4j读取配置文件并使用

    /** 设置配置路径从环境变量读取     * PropertyConfigurator类加载.properties文件的配置    * DOMConfigurator加载.xml文件的配置     ...

  5. jQuery--Excel插件js-xlsx

    参考博客:http://www.jianshu.com/p/74d405940305 github地址:SheetJS / js-xlsx js引入 <script type="tex ...

  6. 【agc006f】Blackout(神仙题)

    [agc006f]Blackout(神仙题) 翻译 给定一个\(n*n\)的网格图,有些格子是黑色的.如果\((x,y),(y,z)\)都是黑色的,那么\((y,x)\)也会被染黑,求最终黑格子数量. ...

  7. codevs2875RY哥查字典

    题目链接:http://codevs.cn/problem/2875/ 题目描述 Description RY哥最近新买了一本字典,他十分高兴,因为这上面的单词都十分的和谐,他天天查字典. 输入描述 ...

  8. 利用poi来向execl中写入对象

    附上jar包下载链接: 附上百度网盘下载连接: 链接:https://pan.baidu.com/s/1t_jXUq3CuhZo9j_UI4URAQ 密码:r2qi package com.wz.po ...

  9. python3.6关键字总结

    模块是个好东西 import keyword # 导入关键字模块 lst = keyword.kwlist # 实例化 print(lst) # 看看有哪些玩意 print(len(lst)) # 貌 ...

  10. 解决Anaconda4.2 Navigator打不开的问题

    参照博客:http://blog.csdn.net/k3v1n1990s/article/details/72975528?utm_source=itdadao&utm_medium=refe ...