1.LuaJit安装

 # cd /usr/local/src
# git clone http://luajit.org/git/luajit-2.0.git
# cd luajit-2.0
# make
# make install

这样luajit就被安装到了/usr/local/ 文件夹下面。

2.ngx_devel_kit

 # cd /usr/local/src
# git clone https://github.com/simpl/ngx_devel_kit.git

3.ngx_lua

 # cd /usr/local/src
# git clone https://github.com/openresty/lua-nginx-module.git

4.告诉nginx编译器去哪儿找到luajit

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

5.编译nginx

 ./configure --prefix=/usr/local/nginx
--with-ld-opt="-Wl,-E,-rpath,/usr/local/lib"
--add-module=/usr/local/src/ngx_devel_kit
--add-module=/usr/local/src/lua-nginx-module

prefix指出nginx将被安装的目录,这里选择了/usr/local/。

6.make

make install  安装

7.测试

 http {

     server {

         location /lua_test {
default_type 'text/plain';
content_by_lua "ngx.say('Hello, World!')";
}
}
}
05-06 20:01