Nginx+lua Environment Construction Notes

Source: Internet
Author: User

1. Download the installation package:
Http://luajit.org/download/LuaJIT-2.0.3.tar.gz?
https://codeload.github.com/simpl/ngx_devel_kit/tar.gz/v0.2.19
https://codeload.github.com/openresty/lua-nginx-module/tar.gz/v0.9.15
Http://nginx.org/download/nginx-1.9.0.tar.gz
Https://codeload.github.com/diegonehab/luasocket/tar.gz/v3.0-rc1
2. Installation dependent
Yum install-y readline-devel Ncurses-devel
Yum Install Libreadline-dev Libncurses5-dev Libpcre3-dev perl
Yum install-y make GCC
Yum Install Readline-devel pcre-devel openssl-devel

3, first install Luajit
Prerequisite: Modify the export PREFIX in the makefile to change the installation path--not necessarily the action required.
Make
Make install
① Configuring environment variables
Export lua_path=/usr/local/luajit/share/lua/?. lua\;?. Lua
Export lua_cpath=/usr/local/luajit/lib/lua/?. so\;?. So
Export path= $PATH:/usr/local/luajit/bin

Export Luajit_lib=/usr/local/luajit/lib
Export luajit_inc=/usr/local/luajit/include/luajit-2.0
②ln-s/usr/local/luajit/lib/libluajit-5.1.so.2/lib64/libluajit-5.1.so.2

4. Installing Nginx
./configure--prefix=/usr/local/nginx--add-module=.. /lua-nginx-module-0.9.15--add-module=. /ngx_devel_kit-0.2.19
Make
Error 1 that occurred:
.. /lua-nginx-module-0.9.15/src/ngx_http_lua_initworkerby.c:in function ' Ngx_http_lua_init_worker ':
.. /lua-nginx-module-0.9.15/src/ngx_http_lua_initworkerby.c:230:error:implicit declaration of function ' ngx_http_set_ Connection_log '
Workaround:
Put
#if defined (nginx_version) && nginx_version >= 1003014

Ngx_http_set_connection_log (R->connection, Clcf->error_log);

#else

C->log->file = clcf->error_log->file;

if (! ( C->log->log_level & Ngx_log_debug_connection)) {
C->log->log_level = clcf->error_log->log_level;
}

#endif
To be replaced by:
#if defined (nginx_version) && nginx_version >= 100900

Ngx_set_connection_log (R->connection, Clcf->error_log);

#elif defined (nginx_version) && nginx_version < 100900 && nginx_version >= 1003014

Ngx_http_set_connection_log (R->connection, Clcf->error_log);

#else

C->log->file = clcf->error_log->file;

if (! ( C->log->log_level & Ngx_log_debug_connection)) {
C->log->log_level = clcf->error_log->log_level;
}

#endif

Error 2 that occurred:
.. /lua-nginx-module-0.9.15/src/ngx_http_lua_timer.c:in function ' Ngx_http_lua_timer_handler ':
.. /lua-nginx-module-0.9.15/src/ngx_http_lua_timer.c:353:error:implicit declaration of function ' ngx_http_set_ Connection_log '
Workaround above, replace the code to

Error 3 that occurred:
Undefined reference to ' pcre_free_study '
Workaround:
Go to pcre.org Download Pcre package, add--with-pcre= in Nginx configure parameter. /pcre-xx.xx--with-pcre-jit

Make install

5, Installation Luasocket
① modify Luasocket/src/makefile, corresponding Luajit specified path
# Luainc_linux:
#/usr/include/lua$ (LUAV)
#/usr/local/include
#/usr/local/include/lua$ (LUAV)
# Where LUA headers is found for Linux builds
Luainc_linux_base?=/usr/local
luainc_linux?=$ (luainc_linux_base)/luajit/include/luajit-2.0
Luaprefix_linux?=/usr/local/luajit
Cdir_linux?=lib/lua
Ldir_linux?=share/lua

② Installation
Make Plat=linux Luav=jit
Make install


Nginx+lua Environment Construction Notes

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.