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

How to install MySQL 5.7.29 with one click using shell script

This article refers to the work of 51CTO blog aut...

Implementation steps for installing java environment in docker

This article is based on Linux centos8 to install...

Let's talk briefly about the changes in setup in vue3.0 sfc

Table of contents Preface Standard sfc writing me...

MySQL group query optimization method

MySQL handles GROUP BY and DISTINCT queries simil...

Analysis of the principles and usage of Linux hard links and soft links

In the Linux system, there is a kind of file call...

How to quickly deploy Redis as a Docker container

Table of contents getting Started Data storage Co...

Vue implements a visual drag page editor

Table of contents Drag and drop implementation Dr...

Detailed explanation of MySQL user rights verification and management methods

This article uses examples to illustrate how to v...

Django+mysql configuration and simple operation database example code

Step 1: Download the mysql driver cmd enters the ...

About dynamically adding routes based on user permissions in Vue

Display different menu pages according to the use...

Analysis of SQL integrity constraint statements in database

Integrity constraints Integrity constraints are f...

Can you do all the web page making test questions?

Web page design related questions, see if you can...

MySQL transaction details

Table of contents Introduction Four characteristi...

MySQL Query Cache Graphical Explanation

Table of contents 1. Principle Overview Query Cac...