Skip to content

Instantly share code, notes, and snippets.

@copuzzle
Last active November 3, 2017 12:40
Show Gist options
  • Save copuzzle/25b5a4e7b346b5eca51b8556777545d3 to your computer and use it in GitHub Desktop.
Save copuzzle/25b5a4e7b346b5eca51b8556777545d3 to your computer and use it in GitHub Desktop.

安装lua扩展的前提是lua已经安装好,如果没有安装,参照

1.http://pecl.php.net/package/lua 下载lua扩展 或者Linux下直接输入 wget -c http://pecl.php.net/package/lua/get/lua-1.0.0.tgz 如果出现域名无法解析的提示

2.解压文件 tar xzvf lua-1.0.0.tgz 进入lua-1.0.0.tgz 运行 phpize 命令 得到如下提示:

表示所下的扩展没有问题,运行 ./configure --prefix=/usr/local/phplua --with-php-config=/usr/local/bin/php-config --with-lua=/usr/local/lua(我自己的lua路径 视情况而定)然后运行 make 得到如下提示:

问题:是liblua.a 静态库 需要指定-fPIC选项 重新编译

解决办法:找到lua的源文件(注意:不是Lua扩展的源文件) 进入/usr/local/src/lua-5.2.3/src 打开Makefile文件 在CFLAG一行 添加选项 -fPIC 像这样:

-fPIC是手动添加的 对lua重新make && make install

3.回到lua-1.0.0目录 重新运行./configure --prefix=/usr/local/phplua --with-php-config=/usr/local/bin/php-config --with-lua=/usr/local/lua 通过了 然后make && make install 找到php.ini文件 添加extension=lua.so

如果出现找不到 lib 的问题,很可能扩展的编译搜索路径和lib位置不一置,可能查看它的探索路径,在conifg.m4 里面,然后通过 ln -s 到它的目的路径 。

参考: http://us1.php.net/manual/en/install.pecl.phpize.php http://program.svn001.net/lua/14164580031421110620.html http://www.itread01.com/content/1493980753.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment