问题描述
我用nginx安装了http-lua-module
,使脚本运行正常,但是现在我要确保nginx
使用LuaJit
而不是Lua
(因为我的研究表明LuaJit更快).
I installed http-lua-module
with nginx, made a script that works perfectly fine, but now I want to be sure that nginx
uses LuaJit
instead of Lua
(because my research shows that LuaJit is faster).
我在.bushrc
中添加了这些代码行:
I added to the .bushrc
those lines of code :
export LD_LIBRARY_PATH=/usr/local/luajit/lib:$LD_LIBRARY_PATH
export LUAJIT_LIB=/usr/local/luajit/lib
export LUAJIT_INC=/usr/local/luajit/include/luajit-2.0
我还重新编译了nginx,现在我只想确保它使用LuaJit.
I also recompiled nginx and now I just want to be sure that it uses LuaJit.
推荐答案
编辑nginx.conf
文件,在server {}
块中添加location
:
Edit your nginx.conf
file, add a location
into your server {}
block:
location = /lua {
default_type text/plain;
content_by_lua '
if jit then
ngx.say(jit.version)
else
ngx.say("Not LuaJIT!")
end
';
}
然后启动您的nginx服务器,然后在curl或您喜欢的Web浏览器中访问/lua.如果看到类似"LuaJIT 2.0.2"的输出,则说明您使用的是LuaJIT.否则,如果看到"Not LuaJIT!",则说明您使用的是标准的Lua 5.1解释器.
Then start your nginx server and then access /lua in curl or in your favorite web browser. If you see outputs like "LuaJIT 2.0.2", then you're using LuaJIT; otherwise, if you see "Not LuaJIT!", then you're using the standard Lua 5.1 interpreter.
另一种更快的方法是检查使用nginx可执行文件链接的Lua DSO文件(如果使用动态链接)(通常是这种情况):
Another quicker way is to check the Lua DSO file linked with your nginx executable if dynamic linking is used (which is usually the case):
ldd /path/to/your/nginx/sbin/nginx|grep -i lua
如果看到类似的东西
libluajit-5.1.so.2 => /usr/local/openresty-debug/luajit/lib/libluajit-5.1.so.2 (0x00007fb3d38f6000)
然后您正在使用LuaJIT.
Then you're using LuaJIT.
这篇关于如何检查nginx是否使用LuaJit而不是Lua?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!