Warning: Array to string conversion in /home/wwwroot/myf5/wp-content/plugins/wpjam-basic/public/wpjam-utils.php on line 496
在安装完NGINX Plus后并启用nginx-plus-module-lua动态模块后,有时候因功能需求还需要引入其它openresty提供的一些lua库,比如lua-resty-core Lua。以下是启用方法:
- 下载clone https://github.com/openresty/lua-resty-core/ 也可以下载openresty包,例如wget wget https://openresty.org/download/openresty-1.27.1.1.tar.gz
- 如果是github直接下载的库,则直接执行 make install即可,它会将相关lua库拷贝到
/usr/local/lib/lua/目录下。 如果是下载的openresty包,则解压后,进入bundle目录找到lua-resty-core目录并执行make install。完成后文件会被拷贝到以下为止:
[myf5@kylinos nginx]$ cd /usr/local/lib/lua/
[myf5@kylinos lua]$ tree -d
.
├── ngx
│ └── ssl
└── resty
└── core
- 在nginx plus启用
lua-resty-core, 在http block下配置lua包路径:
[myf5@kylinos lua]$ cat /etc/nginx/nginx.conf
load_module modules/ndk_http_module.so;
load_module modules/ngx_http_lua_module.so;
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
http {
.....
lua_package_path "/usr/local/lib/lua/?.lua;;";
.....
}
.....
- 测试一下:
[myf5@kylinos nginx]$ cat conf.d/default.conf
server {
listen 80 default_server;
server_name localhost;
location /test {
content_by_lua_block {
local core = require "resty.core"
ngx.say("lua-resty-core loaded successfully!")
}
}
}
测试结果:
$ curl 172.16.10.192/test
lua-resty-core loaded successfully!
Array
文章评论