Reprint Note Address: http://www.cnblogs.com/dongxiao-yang/p/5312285.html
This article mainly uses the manual source installation method to compile the Lua-nginx module into the Nginx source code inside
One: System version
1 cat/etc/issue
CentOS Release 6.7 (Final)
Kernel \ r on an \m
2 cat/proc/version
Linux version 2.6.32-573.el6.x86_64 ([email protected]) (GCC version 4.4.7 20120313 (Red Hat 4.4.7-16) (gcc)) #1 SMP Thu Jul 15:44:03 UTC 2015
Two: Installation
1 Installing Luajit
http://luajit.org/download.html, this download is 2.0.0 version
Install the command Reference http://luajit.org/install.html tutorial, this article directly modifies the default path in the makefile file PREFIX to/opt/luajit-2.0.0.
Make && make install
Installation is complete.
2 Installing Nginx
(1) Download NG source code and unzip
wget http://nginx.org/download/nginx-1.8.1.tar.gz
(2) Download the Ngx_devel_kit (NDK) module here. Extract
(3) Download Ngx_lua here. Unzip
(4) Install Pcre dependent Library
Yum install readline-devel pcre-devel openssl-devel gcc
(5) Set the variable and compile export luajit_lib=/opt/luajit-2.0. 0/lib (depending on the local location)
export luajit_inc =/opt/luajit-2.0 . 0 /include/luajit- (according to the native location) CD nginx -1.8 . 1 /configure--prefix=/opt/nginx-build-1.8 . 1 --add-module=/opt/lua-nginx-module-0.10 . 2 --add-module=/opt/ngx_devel_kit-0.3 . 0rc1
make-j2
Make install
The note here is that many people do not add the option when compiling:--with-ld-opt= "-wl,-rpath,/opt/luajit-2.0.0/lib
This will cause the compiled Nginx to be unable to find the class library located within the Luajit at startup, similar to
/opt/nginx/sbin//opt/nginx/CONF/ nginx.conf/opt/nginx/sbin/whileobject File:no such file or directory
This is a problem many people find using the practice of linking libluajit-5.1.so.2 to the system library, such as http://cywhoyi.iteye.com/blog/2118913, and https://www.ttlsa.com/ Nginx/nginx-modules-ngx_lua, the use of
Ln-s/usr/local/lib/libluajit-5.1.so.2/lib64/
This solves the problem, but it is equivalent to a remediation method.
Reference question Https://github.com/openresty/lua-nginx-module/issues/8 Agentzh's answer
Hello! On Sat, 4 at 1:16 PM, Maanas <[email protected]> wrote:thanks. How can I add this in boot parameters so, I do not have the to do it again. One-to-specify RPATH while building Nginx, for example, plus
--with-ld-optCan resolve problems directly in the compile phase reference NG official installation document definition http://nginx.org/en/docs/configure.html
--with-ld-opt=parameters
-sets additional parameters that'll be used during linking. When using the System PCRE Library under FreeBSD, --with-ld-opt="-L /usr/local/lib"
should is specified.
So the equivalent of directly to the Luajit Lib Library added to the Nginx search library.
(6) Start
Ln-s nginx-build-1.8.1 nginx Set as default path
/opt/nginx/sbin/nginx-c/opt/nginx/conf/nginx.conf
Startup success
Resources
1 How to install the Nginx_lua_module module
2 Lua-nginx-module
3 openresty A scalable, NGINX-based WEB platform
Nginx Installation Lua-nginx-module Module