1.下载LUAJIT2.0,ngx_lua,nginx等文件,地址如下:
LUAJIT2.0:http://luajit.org/download/LuaJIT-2.0.0.tar.gz
ngx_lua:https://github.com/chaoslawful/lua-nginx-module/archive/master.zip
nginx:http://nginx.org/download/nginx-1.2.6.tar.gz
2.解压缩以上的压缩包,并放到某个指定的目录,例如/root
3.安装LUAJIT2.0
例如LUAJIT2.0的压缩包解压缩到/root/LuaJIT-2.0.0了,
cd /root/LuaJIT-2.0.0 [root@localhost ~]#make && make install执行以上shell命令后,你会在/usr/local/lib,/usr/local/include这个两个目录看到LuaJIT2.0的相关文件
4.安装nginx和ngx_lua模块
如果没有zlib库,则先安装zlib库,例如用yum install zlib-devel命令来安装
例如把nginx压缩包解压缩到/root/nginx-1.2.6,ngx_lua压缩包解压缩到/root/lua-nginx-module-master
[root@localhost ~]#cd /root/nginx-1.2.6 [root@localhost ~]#export LUAJIT_LIB=/usr/local/lib [root@localhost ~]#export LUAJIT_INC=/usr/local/include/luajit-2.0 [root@localhost ~]#./configure --with-ld-opt="-Wl,-rpath,$LUAJIT_LIB" --add-module=/root/lua-nginx-module-master --without-http_rewrite_module [root@localhost ~]#make -j2 [root@localhost ~]#make install执行以上shell命令则将nginx安装到/usr/local/nginx下了,并且ngx_lua模块也添加到nginx了。
5.下载lua-iconv,luarocks等文件,地址如下:
https://github.com/downloads/ittner/lua-iconv/lua-iconv-7.tar.gz
http://luarocks.org/releases/luarocks-2.0.12.tar.gz
6.安装luarocks
之所以安装luarocks,是因为luarocks可以帮你安装许多lua的第三方库,非常方便,而且在安装luajit之后再源码编译安装lua-iconv比较费劲。
假如你把luarocks的压缩包解压缩到/root/luarocks-2.0.12,用以下命令来安装luarocks
[root@localhost ~]#cd /root/luarocks-2.0.12 [root@localhost ~]#./configure --with-lua="/usr/local" --prefix="/usr/local" --lua-suffix="jit" --with-lua-include="/usr/local/include/luajit-2.0" --force-config [root@localhost ~]#make && make install由于没有安装Lua,在安装luarocks需要指定luajit的安装路径
7.安装lua-iconv模块
执行以下命令就能将lua-iconv模块安装好,可以在/usr/local/lib/lua/5.1目录看到一个iconv.so动态链接库
[root@localhost ~]#luarocks install lua-iconv
参考:
http://luajit.org/install.html
http://wiki.nginx.org/HttpLuaModule#Installation
https://gist.github.com/1125331
https://github.com/chaoslawful/lua-nginx-module/issues/8
https://github.com/ittner/lua-iconv
http://www.luarocks.org/