checking for LuaJIT 2.x ... not found ./configure: error: unsupported LuaJIT version; ngx_http_lua_module requires LuaJIT 2.x.
这个错误是因为需要安装 LuaJIT 2.x。以下是安装步骤
1. 首先安装必要的编译工具和依赖
Ubuntu/Debian:
apt-get install build-essential
CentOS 9 :
# 安装开发工具组
dnf groupinstall "Development Tools"
# 安装必要的依赖
dnf install pcre-devel zlib-devel openssl-devel gcc make \
perl-IPC-Cmd perl-Getopt-Long perl-Data-Dumper \
luajit-devel luajit
2.设置环境变量
# 设置 LuaJIT 路径
export LUAJIT_LIB=/usr/lib64
export LUAJIT_INC=/usr/include/luajit-2.1
# 添加到系统配置文件以持久化
echo "export LUAJIT_LIB=/usr/lib64" >> /etc/profile.d/luajit.sh
echo "export LUAJIT_INC=/usr/include/luajit-2.1" >> /etc/profile.d/luajit.sh
source /etc/profile
3. 重新配置 Nginx/Tengine
./configure \
--prefix=/usr/local/nginx \
--user=www \
--group=www \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-pcre \
--with-http_realip_module \
--with-http_gunzip_module \
--with-http_secure_link_module \
--with-stream \
--with-stream_ssl_module \
--with-stream_sni \
--with-syslog \
--with-ld-opt="-Wl,-rpath,/usr/lib64" \
--with-luajit-lib=/usr/lib64 \
--with-luajit-inc=/usr/include/luajit-2.1
如果还是不成功,可以尝试手动编译 LuaJIT
# 下载并解压 LuaJIT
cd /usr/local/src
wget https://github.com/openresty/luajit2/archive/refs/tags/v2.1-20231117.tar.gz
tar -zxf v2.1-20231117.tar.gz
cd luajit2-2.1-20231117
# 编译安装
make
make install PREFIX=/usr
# 更新系统库缓存
ldconfig
然后重新设置环境变量并配置 Tengine。
如果仍然遇到问题,可以检查:
-
验证 LuaJIT 安装:
# 检查 LuaJIT 版本 luajit -v
-
检查库文件
ls -l /usr/lib64/libluajit*
ls -l /usr/include/luajit-2.1/ -
检查环境变量:
echo $LUAJIT_LIB echo $LUAJIT_INC
-
如果出现其他错误,可以查看配置日志:
cat objs/autoconf.err