Nginx and LUA development environment construction

Source: Internet
Author: User

First download the latest version of the relevant software installation files.

Nginx:http://nginx.org/en/download.html

Luajit:http://luajit.org/download.html

lua-nginx-module:https://github.com/openresty/lua-nginx-module/releases/tag/v0.9.16

ngx_devel_kit:https://github.com/simpl/ngx_devel_kit/releases/tag/v0.2.19

[email protected] src]# LL-Ttotal22408-rw-r--r--.1Root root65029Sep -  the:xxngx_devel_kit-0.2. +. tar.gz-rw-r--r--.1Root root523900Sep -  the:xxlua-nginx-module-0.9. -. tar.gz-rw-r--r--.1Root root847615Sep -  the:xxluajit-2.0.4. tar.gz-rw-r--r--.1Root root832104Sep8  -: atnginx-1.8.0. tar.gz

1. first unzip the installation Luajit

Tar zxvf luajit-2.0. 4. tar.gz

CD luajit-2.0. 4 go in.

Make && make install

Get.

Then unzip the ngx_devel_kit-0.2 separately. tar.gz and lua-nginx-module-0.9. tar.gz.

2. re-unzip the installation nginx and add the Ngx_devel_kit and Lua-nginx-module modules:

[Email protected] nginx]#/configure--add-module=/usr/local/src/lua-nginx-module-0.9.  -  >--add-module=/usr/local/src/ngx_devel_kit-0.2. 19

[[email protected] nginx]# make && make install

When the installation is complete, the test will usually error:

[[email protected] sbin]#./Nginx.  while loading shared libraries:libluajit-5.1. 2 object file:no such file or directory

Workaround:

" /usr/local/lib " >/etc/ld.so.conf.d//etc/ld.so.conf.d/usr_local_lib.conf/usr/local/lib[[ Email protected] lib]# Ldconfig

In the test, OK.

[Email protected] sbin]#.Nginx[[email protected] sbin]# PS-elf|grep nginx1S Root8758     1  0   the   0-1612- the: -?xx:xx:xxNginx:master process.Nginx5S Nobody8759  8758  0   the   0-1662- the: -?xx:xx:xxNginx:worker Process5S Nobody8760  8758  0   the   0-1662- the: -?xx:xx:xxNginx:worker Process0S Root8762  1723  0   the   0-1088- the: -pts/1    xx:xx:xxgrep ngin

Configuration of the NDK and Lua-nginx-module Nginx should not be larger than the original :

[[email protected] sbin]# ls-7.1M14.4M:  Nginx12.8M Sep  9: Nginx.old

3. Test the LUA module configuration for success:

In the nginx.conf file, add:

        Location/Lua {                set'Hello, world. " ;                 '                        " Text/plain " ;                        Ngx.say (NGX. var . Test);                 ' ;        }

Then nginx-t; Test error-free, then nginx-s reload; Reload the nginx.conf file

Then visit 192.168.1.200/lua:

See the results, indicating nginx, the Lua development environment was built successfully.

The meaning of the above configuration is to define a variable $test and then output its value in Text/pain format. $test define variables, reminiscent of the definition of PHP and shell variables.

In fact, Nginx and Lua have a dedicated development environment that has been configured: Openresty and Tengine

Nginx and LUA development environment construction

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.