1.下载相关软件
需要软件有:Nginx,LuaJIT,ngx_devel_kit,ngx_lua等安装文件
安装Lua或者LuaJIT都是可以的,但是出于效率的考虑,推荐安装LuaJIT
shell> wget http://luajit.org/download/LuaJIT-<VERSION>.tar.gz shell> tar zxvf LuaJIT-<VERSION>.tar.gz shell> cd LuaJIT-<VERSION> shell> make shell> make install
因为安装在缺省路径,所以LuaJIT对应的lib,include均在/usr/local目录里。
shell> export LUAJIT_LIB=/usr/local/lib shell> export LUAJIT_INC=/usr/local/include/luajit-<VERSION>
注意:lua模块支持的nginx版本
Nginx Compatibility
The latest version of this module is compatible with the following versions of Nginx:
- 1.11.x (last tested: 1.11.2)
- 1.10.x
- 1.9.x (last tested: 1.9.15)
- 1.8.x
- 1.7.x (last tested: 1.7.10)
- 1.6.x
Nginx cores older than 1.6.0 (exclusive) are not supported
nginx编译参数:
./configure --prefix=/usr/local/nginx-lua-1.11.7 --with-pcre --with-http_stub_status_module --with-http_gzip_static_module --add-module=/opt/lua-nginx-module-0.10.7 --add-module=/opt/ngx_devel_kit-0.3.0 --with-ld-opt="-Wl,-rpath,/usr/local/lib"
2.编译安装
make -j2 && make install
3.查看是否缺失模块
ldd nginx
试着启动一下Nginx看看,如果你运气不好的话,可能会遇到如下错误:
cannot open shared object file: No such file or directory
这是神马情况?可以用ldd命令来看看:
shell> ldd /path/to/nginx libluajit-<VERSION>.so => not found
此类问题通常使用ldconfig命令就能解决:
shell> echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
shell> ldconfig
再试着启动Nginx看看,应该就OK了。
4.fpm打包
fpm打包教程网上有很多,这里就不重复了
github上有现成的开源项目
http://openresty.org/cn/