Install the lua development environment in linux

Source: Internet
Author: User

Install the lua development environment in linux

I have introduced the establishment of the nginx + lua environment. Here we will learn about the installation of the lua development environment.

Currently, the lua version has been updated to lua5.3, but we have installed lua5.1 here. Because 5.1 has been running for many years, many modules are based on this version, such as lua_gd.

Installation:

1. First install lua-related dependencies

Yum install readline-dev readline-devel

2. Install lua5.1

 

wget http://www.lua.org/ftp/lua-5.1.0.tar.gztar -zxvf lua-5.1.0.tar.gzmake linux testmake install

 

Lua CKS has a module management tool, similar to yum. We can use luarocks to install related modules.

1. Install

 

wget http://luarocks.org/releases/luarocks-2.2.1.tar.gztar zxpf luarocks-2.2.1.tar.gzcd luarocks-2.2.1./configure
The following prompt is displayed:

 

 

Lua interpreter found: /usr/bin/lua...Lua version detected: 5.1lua found in $PATH: /usr/binChecking Lua includes... lua.h not found (looked in /usr/include, /usr/include/lua/5.1, /usr/include/lua5.1)You may want to use the flag --with-lua or --with-lua-include. See --help.configure failed.

 

The system prompts that lua. h cannot be found. By default, it will be searched under/usr, because we need to specify the directory of lua. h.

 

find / -name lua.h/usr/local/luajit/include/luajit-2.0/lua.h/usr/local/src/lua/lua-5.1.5/src/lua.h/usr/local/src/lua/LuaJIT-2.0.4/src/lua.h/usr/local/include/luajit-2.0/lua.h/usr/local/include/lua.h

Re-compile and install:

 

./configure --with-lua=/usr/local --with-lua-include=/usr/local/includemake bootstrap
We will install luarocks to/usr/local and add the following environment variables to use them directly:

 

Export PATH =/usr/local/bin: $ PATH

For details about available modules of lua, refer to http://luarocks.org/repositories/rocks:

 

[root@usvr-126 local]# luarocks install luafilesystemInstalling https://rocks.moonscript.org/luafilesystem-1.6.3-1.src.rock...Using https://rocks.moonscript.org/luafilesystem-1.6.3-1.src.rock... switching to 'build' modegcc -O2 -fPIC -I/usr/local/include -c src/lfs.c -o src/lfs.ogcc -shared -o lfs.so -L/usr/local/lib src/lfs.oUpdating manifest for /usr/local/lib/luarocks/rocksluafilesystem 1.6.3-1 is now built and installed in /usr/local (license: MIT/X11)
After the installation is complete, an lfs is generated under/usr/local/lib/lua/5.1. so file, we only need to copy this file to the custom LUA_PATH in nginx, You can reference this library, call the function in it.

 

For example, in the nginx configuration file, reference:

 

Lua_package_path '/usr/local/nginx/lua /?. Lua; 'lua _ package_cpath '/usr/local/nginx/lua/lib /?.?;; '; # ";" Indicates the original search range.
Note: You can define the path as the default path.

 

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.