1.下载luajit
wget http://luajit.org/download/LuaJIT-2.0.4.tar.gz
tar xf LuaJIT-2.0.4.tar.gz
cd LuaJIT-2.0.4
make PREFIX=/usr/local/luajit
make install PREFIX=/usr/local/luajit
export LUAJIT_LIB=/usr/local/luajit/lib
export LUAJIT_INC=/usr/local/luajit/include/luajit-2.0
2.下载ngx_devel_kit
cd /usr/local/src/
wget https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz
tar -xf v0.3.0.tar.gz
3.下载lua-nginx-module
wget https://github.com/openresty/lua-nginx-module/archive/v0.10.8.tar.gz
tar xf v0.10.8.tar.gz
尽量下载最新版
最新版下载地址:https://github.com/openresty/lua-nginx-module#installation
4.nginx -V查看nginx的编译参数
在原有参数上加上:
--add-module=/usr/local/src/ngx_devel_kit-0.3.0
--add-module=/usr/local/src/lua-nginx-module-master
我的 最终参数如下:
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-pcre-jit --add-module=/usr/local/src/ngx_devel_kit-0.3.0 --add-module=/usr/local/src/lua-nginx-module-master --add-module=/usr/local/src/nginx-rtmp-module
5.make && make install
6检测nginx
nginx -t
nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No such file or directory
# 解决: 查找文件,创建软连接
find / -name "libluajit-5.1.so.2"
ln -s /usr/local/luajit/lib/libluajit-5.1.so.2 /lib64/
nginx: [alert] detected a LuaJIT version which is not OpenResty‘s; many optimizations will be disabled and performance will be compromised (see https://github.com/openresty/luajit2 for OpenResty‘s LuaJIT or, even better, consider using the OpenResty releases from https://openresty.org/en/download.html)
需要更换luajit版本
下载地址:https://github.com/openresty/luajit2