Install PHP's LUA extension library under Linux

Source: Internet
Author: User

First, install LUA 5.3.4

Download

http://www.lua.org/ftp/lua-5.3. 4 . Tar.gztar xvf Lua-5.3. 4 . TAR.GZCD Lua-5.3. 4

Important: Enter the unzipped path CD .../lua-5.3.4/src open the makefile file on the Cflag line to add options-fpic like this:

The line that found the source file is replaced

Cflags=-o2-wall-dlua_compat_all $ (syscflags)-fpic $ (mycflags)

Then compile, install

Make Linux  sudo make install

Install LUA successfully after execution to see if the LUA version is the version you just installed

[Email protected]:~/lua-5.3. 4$ lua-5.3. 4  1994- lua.org, Puc-rio

See if there is a lua.h under the/usr/local/include/path to create a soft chain for the header file

[Email protected]:/usr/Local/include$ ls lauxlib.h libssh2.h libssh2_publickey.h libssh2_sftp.h luaconf.h lua.h lua.hpp lualib.h[email Prot Ected]:/usr/Local/include$ ln-s/usr/Local/include/lua.h/usr/include/lua/LUA.HLN: Unable to create symbolic link'/usr/include/lua/lua.h': No file or directory [email protected]:/usr/Local/include$ ln-s/usr/Local/include/lua.h/usr/include/lua/LUA.HLN: Unable to create symbolic link'/usr/include/lua/lua.h': No file or directory [email protected]:/usr/Local/include$ mkdir-p/usr/include/luamkdir: Invalid option--PTry'mkdir--help'  forMore information. [Email protected]:/usr/Local/include$ Mkdir-r/usr/include/luamkdir: Invalid option--RTry'mkdir--help'  forMore information. [Email protected]:/usr/Local/include$ mkdir-/usr/include/Luamkdir: Unable to create directory"-": Insufficient permissions mkdir: Unable to create directory"/usr/include/lua": Insufficient permissions [email protected]:/usr/Local/include$ sudo mkdir-/usr/include/Lua[email protected]:/usr/Local/include$ ln-s/usr/Local/include/lua.h/usr/include/lua/LUA.HLN: Unable to create symbolic link'/usr/include/lua/lua.h': Insufficient permissions [email protected]:/usr/Local/include$ sudo ln-s/usr/Local/include/lua.h/usr/include/lua/Lua.h[email protected]:/usr/Local/include$

Put LIBLUA.A in the/usr/lib directory, first find LIBLUA.A file in which location, generally in the/USR/LOCAL/LIB/LIBLUA.A

[Email protected]:/usr/local//usr/local/lib/liblua.a[email protected]:/usr/ local/include$ cp/usr/local/lib/liblua.a/usr/lib/LIBLUA.ACP: Cannot create normal file '/ USR/LIB/LIBLUA.A': Insufficient authority [email protected]:/usr/local/include$ sudo cp/usr/  Local/lib/liblua.a/usr/lib/liblua.a[email protected]:/usr/local/include$

If LUA is not installed, prompt for error messages when./configured

Error  in <lua-dir>/include/

Second, install Phplua extension

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

Tar xvf lua-2.0.3.tgzcd Lua-2.0. 3 phpize. /configure

Compiling, installing

[Email protected]:~/lua-2.0.3$ Make/bin/bash/home/tinywan/lua-2.0.3/libtool--mode=compile cc ...[Email protected]:~/lua-2.0.3$ sudo make install/bin/bash/home/tinywan/lua-2.0.3/libtool--mode=install CP./lua.la/home/tinywan/lua-2.0.3/modulesLIBTOOL:INSTALL:CP./.libs/lua.so/home/tinywan/lua-2.0.3/modules/LUA.SOLIBTOOL:INSTALL:CP./.libs/lua.lai/home/tinywan/lua-2.0.3/modules/Lua.lalibtool:finish:PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/sbin"Ldconfig-n/home/tinywan/lua-2.0.3/Modules----------------------------------------------------------------------Libraries have been installedinch:   /home/tinywan/lua-2.0.3/modulesif ever happen to want to link against installed librariesinchA given directory, Libdir, you must either use Libtool, andSpecify the full pathname of the library,orUse the'-llibdir'flag during linking and  DoAt 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-Your system administrator add Libdir to'/etc/ld.so.conf'See all operating system documentation about shared libraries forMore information, such as the LD (1) andLd.so (8) manual pages.----------------------------------------------------------------------Installing Shared extensions:/usr/lib/php/20151012/

View Lua.so File

[Email protected]:/usr/lib/php/20151012$ lsbuild        ctype.so  exif.so      ftp.so      iconv.so  lua.so

Modify PHP configuration file

sudo vim/etc/php/7.0/cli/php.ini# Add content extension=/usr/lib/php/20151012 /Lua.so[email protected]:/usr/lib/php/20151012$ php-m | grep lualua

Installation Complete

Third, testing

File test_lua.php

<?PHP$lua=NewLua ();$lua-Eval(<<<CODEfunctionDummy (foo,bar)Print(foo, ",",bar)EndCODE);$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), "-")));?>

Execution Result:

[Email protected]:~/php7$ php Test_lua. php Lua,Geiliablelua, geiliablestring (11) "1.0-2.0-3.0"

Install PHP's LUA extension library under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.