登录 |

安装ngx_lua

2012年03月9日 上午 33:17 | 作者:

推荐使用openresty,自带所有扩展依赖包:http://openresty.org/#Download

wget http://agentzh.org/misc/nginx/ngx_openresty-1.0.11.21.tar.gz
tar xzvf ngx_openresty-1.0.11.21.tar.gz
cd ngx_openresty-VERSION/
./configure --with-luajit
make
make install

搞定!喜欢从头开始继续看!
—————————————————————————————————————

1、安装Luajit
http://luajit.org/download.html

wget http://luajit.org/download/LuaJIT-2.0.0-beta9.tar.gz
tar xvf LuaJIT-2.0.0-beta9.tar.gz
make
make PREFIX=/home/myself/lj2  # 指定安装目录
sudo make install

==== Installing LuaJIT 2.0.0-beta9 to /usr/local ====
mkdir -p /usr/local/bin /usr/local/lib /usr/local/include/luajit-2.0 /usr/local/share/man/man1 /usr/local/lib/pkgconfig /usr/local/share/luajit-2.0.0-beta9/jit /usr/local/share/lua/5.1 /usr/local/lib/lua/5.1
……
==== Successfully installed LuaJIT 2.0.0-beta9 to /usr/local ====

#导出LUAJIT库目录,ngx_lua扩展需要
export LUAJIT_LIB=/usr/local/lib   # libluajit-5.1.so所在的目录,mkdir -p第二个目录
export LUAJIT_INC=/usr/local/include/luajit-2.0 # luajit.h所在目录,mkdir -p第三个目录

2、安装Nginx

下载最新版本的ngx_devel_kit、ngx_lua、nginx:

  1. ngx_devel_kit
    https://github.com/simpl/ngx_devel_kit/tags
  2. ngx_lua
    https://github.com/chaoslawful/lua-nginx-module/tags
  3. nginx(tengine )
    http://nginx.org/en/download.html http://tengine.taobao.org/download.html
wget 'https://github.com/chaoslawful/lua-nginx-module/zipball/master'
unzip chaoslawful-lua-nginx-module-v0.5.0rc17-1-g58cd7f0.zip
wget 'https://github.com/simpl/ngx_devel_kit/zipball/master'
unzip simpl-ngx_devel_kit-v0.2.17-7-g24202b4.zip
wget 'http://nginx.org/download/nginx-1.0.11.tar.gz'
tar -xzvf nginx-1.0.11.tar.gz
cd nginx-1.0.11/

./configure --prefix=/opt/nginx \  #指定安装目录
--add-module=/path/to/ngx_devel_kit \
--add-module=/path/to/lua-nginx-module

make -j2
make install