How to install lua-nginx-module module in Nginx

How to install lua-nginx-module module in Nginx

ngx_lua_module is an nginx http module that embeds the lua parser into nginx to parse and execute web backend scripts written in lua language

The features are very good, you can check it out on Baidu. Here is mainly to demonstrate how to install the lua-nginx-module module under Nginx

Of course, if you have never installed Nginx before and find the installation troublesome, you can directly download openresty for quick and easy installation, http://openresty.org/cn/installation.html (the work of Zhang Yichun, a big shot of Alibaba, I admire it~~~)

1. Download and install LuaJIT 2.1 (2.0 or 2.1 are both supported, 2.1 is officially recommended): http://luajit.org/download.html

cd /usr/local/src
wget http://luajit.org/download/LuaJIT-2.1.0-beta2.tar.gz
tar zxf LuaJIT-2.1.0-beta2.tar.gz
cd LuaJIT-2.1.0-beta2
make PREFIX=/usr/local/luajit
make install PREFIX=/usr/local/luajit

2. Download the ngx_devel_kit (NDK) module: https://github.com/simpl/ngx_devel_kit/tags, no installation is required

cd /usr/local/src
wget https://github.com/simpl/ngx_devel_kit/archive/v0.2.19.tar.gz
tar -xzvf v0.2.19.tar.gz

3. Download the latest lua-nginx-module module: https://github.com/openresty/lua-nginx-module/tags, no installation is required

cd /usr/local/src
wget https://github.com/openresty/lua-nginx-module/archive/v0.10.2.tar.gz
tar -xzvf v0.10.2.tar.gz

4.nginx -V to view the compiled configuration

nginx -V

The author's configuration is as follows:

Copy the code as follows:
--prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-ipv6 --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-openssl=../openssl-1.0.2h --with-pcre=../pcre-8.38 --with-pcre-jit --with-ld-opt=-ljemalloc --with-ld-opt=-Wl,-rpath,/usr/local/luajit/lib --add-module=/usr/local/src/ngx_devel_kit-0.2.19 --add-module=/usr/local/src/lua-nginx-module-0.10.2

5. Enter the decompressed directory where nginx was installed before, recompile and install (under the configuration obtained by nginx -V, add the directories of ngx_devel_kit-0.2.19 and ua-nginx-module-0.10.2), the final configuration is as follows:

Setting Environment Variables

export LUAJIT_LIB=/usr/local/luajit/lib
export LUAJIT_INC=/usr/local/luajit/include/luajit-2.1

Copy the code as follows:
./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-ipv6 --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-openssl=../openssl-1.0.2h --with-pcre=../pcre-8.38 --with-pcre-jit --with-ld-opt='-ljemalloc' --with-ld-opt="-Wl,-rpath,/usr/local/luajit/lib" --add-module=/usr/local/src/ngx_devel_kit-0.2.19 --add-module=/usr/local/src/lua-nginx-module-0.10.2

6. Compile and install

make -j2
make install

7. Check whether the compilation is successful

Add the following code to /usr/local/nginx/conf/nginx.conf:

location /hello_lua { 
   default_type 'text/plain'; 
   content_by_lua 'ngx.say("hello, lua")'; 
}

Restart nginx:

service nginx restart

When you visit 10.211.55.3/hello_lua, "hello, lua" will appear, indicating that the installation is successful.

hello, lua

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Detailed explanation of time zone issues in Lua game development tutorial
  • Lua development environment configuration tutorial in various operating systems
  • Simple application of MVC framework in lua development
  • Install Nginx+Lua development environment
  • Centos7 installation of Nginx integrated Lua sample code
  • Cocos2dx+lua realizes eraser function
  • Explanation of the use of three loop statements in Lua
  • Variables and assignment methods in Lua
  • Introduction and advantages and disadvantages of Lua coroutine
  • Luvit writes Lua applications like Node.js

<<:  Introduction to Vue3 Composition API

>>:  Win2008 R2 mysql 5.5 zip format mysql installation and configuration

Recommend

Vue.js implements music player

This article shares the specific code of Vue.js t...

CSS makes tips boxes, bubble boxes, and triangles

Sometimes our pages will need some prompt boxes o...

JavaScript implements simple date effects

The specific code of JavaScript date effects is f...

What to do if you forget the initial password when installing MySQL on Mac

Forgetting the password is a headache. What shoul...

vite2.x implements on-demand loading of ant-design-vue@next components

1. Use version vite:2.0 ant-design-vue: 2.0.0-rc....

Detailed explanation of how components communicate in React

1. What is We can split the communication between...

Detailed explanation of MySQL user rights management

Table of contents Preface: 1. Introduction to Use...

Solve the scroll-view line break problem of WeChat applet

Today, when I was writing a small program, I used...

How to configure Linux CentOS to run scripts regularly

Many times we want the server to run a script reg...

An article to understand what is MySQL Index Pushdown (ICP)

Table of contents 1. Introduction 2. Principle II...

MySQL slow query and query reconstruction method record

Preface What is a slow query and how to optimize ...

CSS eight eye-catching HOVER effect sample code

1. Send effect HTML <div id="send-btn&quo...

VMware WorkStation 14 pro installation Ubuntu 17.04 tutorial

This article records the specific method of insta...