Build nginx and lua development environment, nginxlua
Download the installation file of the latest software version.
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
[root@localhost src]# ll -ttotal 22408-rw-r--r--. 1 root root 65029 Sep 13 09:00 ngx_devel_kit-0.2.19.tar.gz-rw-r--r--. 1 root root 523900 Sep 13 09:00 lua-nginx-module-0.9.16.tar.gz-rw-r--r--. 1 root root 847615 Sep 13 09:00 LuaJIT-2.0.4.tar.gz-rw-r--r--. 1 root root 832104 Sep 8 13:23 nginx-1.8.0.tar.gz
1.Unzip and install LuaJIT
Tar zxvf LuaJIT-2.0.4.tar.gz
Cd LuaJIT-2.0.4 in
Make & make install
Done.
Then extract the ngx_devel_kit-0.2.19.tar.gz and lua-nginx-module-0.9.16.tar.gz separately
2.Decompress and install nginx, and add the ngx_devel_kit and lua-nginx-module modules:
[root@localhost nginx]# ./configure --add-module=/usr/local/src/lua-nginx-module-0.9.16 \> --add-module=/usr/local/src/ngx_devel_kit-0.2.19
[root@localhost nginx]# make && make install
After the installation is complete, an error is reported during the test:
[root@localhost sbin]# ./nginx./nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No such file or directory
Solution:
[root@localhost lib]# echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf[root@localhost lib]# cat /etc/ld.so.conf.d/usr_local_lib.conf/usr/local/lib[root@localhost lib]# ldconfig
In the test, OK.
[root@localhost sbin]# ./nginx[root@localhost sbin]# ps -elf|grep nginx1 S root 8758 1 0 80 0 - 1612 - 09:26 ? 00:00:00 nginx: master process ./nginx5 S nobody 8759 8758 0 80 0 - 1662 - 09:26 ? 00:00:00 nginx: worker process5 S nobody 8760 8758 0 80 0 - 1662 - 09:26 ? 00:00:00 nginx: worker process0 S root 8762 1723 0 80 0 - 1088 - 09:26 pts/1 00:00:00 grep ngin
Nginx with ndk and lua-nginx-module configured must be larger.:
[root@localhost sbin]# ls -lhtotal 7.1M-rwxr-xr-x. 1 root root 4.4M Sep 13 09:20 nginx-rwxr-xr-x. 1 root root 2.8M Sep 9 10:50 nginx.old
3.Test whether the Lua module configuration is successful:
Add the following to the nginx. conf file:
location /lua { set $test "hello, world."; content_by_lua ' ngx.header.content_type = "text/plain"; ngx.say(ngx.var.test); '; }
Then nginx-t; test without errors, then nginx-s reload; reload the nginx. conf file
Then access 192.168.1.200/lua:
The result indicates that the nginx and Lua development environments are successfully set up.
The preceding configuration defines a variable $ test and outputs its value in text/pain format. $ Test defines variables, which reminds people of the definition of php and shell variables.
In fact, nginx and lua have a specially configured Development Environment: OpenResty and Tengine