2022年6月15日11:02:14
drwxr-xr-x. 2 root root 123 Jun 8 18:18 bin 可执行文件目录
-rw-r--r--. 1 root root 22924 May 18 03:15 COPYRIGHT
drwxr-xr-x. 6 root root 56 Jun 8 17:59 luajit luajit目录
drwxr-xr-x. 5 root root 105 Jun 8 17:59 lualib lua的引用库目录
drwxr-xr-x. 11 root root 151 Jun 8 18:00 nginx nginx目录
drwxr-xr-x. 4 root root 28 Jun 8 17:59 openssl111 openssl目录
drwxr-xr-x. 3 root root 17 Jun 8 17:59 pcre Perl的库
drwxr-xr-x. 47 root root 4096 Jun 8 18:18 pod 基本是一些文档
-rw-r--r--. 1 root root 235463 May 18 03:15 resty.index
drwxr-xr-x. 5 root root 66 Jun 8 18:38 site
drwxr-xr-x. 3 root root 17 Jun 8 17:59 zlib zlib库
更重要的是bin目录下的一些东西
-rwxr-xr-x. 1 root root 19185 May 18 03:15 md2pod.pl
-rwxr-xr-x. 1 root root 15994 May 18 03:15 nginx-xml2pod
lrwxrwxrwx. 1 root root 37 Jun 8 17:59 openresty -> /usr/local/openresty/nginx/sbin/nginx nginx可执行文件
-rwxr-xr-x. 1 root root 63510 May 18 03:15 opm 包管理工具opm
-rwxr-xr-x. 1 root root 36623 May 18 03:15 resty OpenResty CLI的命令行
-rwxr-xr-x. 1 root root 14957 May 18 03:15 restydoc 文档查看工具,就是看pod里面的 这个很重要,开发的时候全靠这个
-rwxr-xr-x. 1 root root 8873 May 18 03:15 restydoc-index 文档索引
推荐一个博客:https://yxudong.github.io/categories/OpenResty/
因为lua和luajit差别有点大,想要写好高性能的luajit代码,需要非常多的经验
OpenResty 完全开发指南
https://wiki.shileizcc.com/confluence/pages/viewpage.action?pageId=47415930
OpenResty 附带了非常完善的用户参考手册 restydoc,提供与 UNIX 手册 man 相同的功能,可以检索 OpenResty 里所有组件的帮助文档,包括但不限于:
OpenResty 各个组件的介绍和用法;
OpenResty 指令和功能接口的用法;
Nginx 介绍、用法、基本工作原理;
Lua/LuaJIT 语法要素。
下面示范了一些 restydoc 的用法,其中的 “-s” 参数用来指定搜索手册里的小节名:
# Nginx 的说明
$ /usr/local/openresty/bin/restydoc nginx
# LuaJIT 的说明
$ /usr/local/openresty/bin/restydoc luajit
# 包管理工具 opm 说明
$ /usr/local/openresty/bin/restydoc opm
# 命令行工具 resty 的说明
$ /usr/local/openresty/bin/restydoc resty-cli
# ngx_echo 组件的说明
$ /usr/local/openresty/bin/restydoc ngx_echo
# ngx_lua 的说明
$ /usr/local/openresty/bin/restydoc ngx_lua
# stream_lua 说明
$ /usr/local/openresty/bin/restydoc stream_lua
# lua-cjson 说明
$ /usr/local/openresty/bin/restydoc lua-cjson
# 反向代理指令 proxy_pass 的说明
$ /usr/local/openresty/bin/restydoc -s proxy_pass
# content_by_lua_block 指令的说明
$ /usr/local/openresty/bin/restydoc -s content_by_lua_block
# 功能接口 ngx.say 的说明
$ /usr/local/openresty/bin/restydoc -s ngx.say
# lua 函数 concat 的说明
$ /usr/local/openresty/bin/restydoc -s concat
对于使用 opm 安装的组件,需要使用 “-r” 参数指定安装目录,例如:
$ /usr/local/openresty/bin/restydoc -r /usr/local/openresty/site -s lua-resty-http
OpenResty 命令行工具
OpenResty 在 bin 目录下提供一个命令行工具 resty(注意命令不是 resty-cli)。可以把它作为 Lua 语言的解释器(但运行在 OpenResty 环境里)代替标准的 Lua 5.x,写出类似 Perl、Python 那样易用的脚本,是测试/运维工程师的利器。
resty 的工作原理是启动了一个 “无服务” 的 Nginx 示例,禁用了 daemn 等大多数指令,也没有配置监听端口,只是在 worker 集成里用定时器让 Lua 代码在 Nginx 里执行。
使用 “-e” 参数可以在命令行里直接执行 Lua 代码,例如:
$ resty -e "print('hello OpenResty')"
hello OpenResty
这种方式只适合执行很小的代码片段,更好的方式是利用 UNIX 的 “Shebang” (#!),在脚本文件里的一行指定 resty 作为解释器,能够书写任意长度和复杂度的代码,而且更利于管理维护。
刚才的命令行用法可以改成写成下面的脚本文件:
hello.lua
#!/usr/local/openresty/bin/resty
local n = #arg
print("args count = ", n)
for i = i,n do
print("arg ", i , ": ", arg[i])
end
使用参数执行脚本 hello.lua 结果是:
$ chmod +x hello.lua
$ ./hello.lua FireEmblem Heroes
resty 工具还有很多选项用于配置行为,非常灵活,“-e” 之外较常用的有:
-c:指定最大并发连接数(默认值是 64);
-I:指定 Lua 库的搜索路径;
-l:指定加载某个 Lua 库;
--http-conf:定制在 http 域里的指令;
--main-include:定制在 main 域里的指令;
--shdict:定制使用的共享内存。
--resolve-upv6:允许解析 ipv6 的地址。
OpenResty 变量
"变量" 是 Nginx 内部保存的运行时 HTTP/TCP 请求相关数据,可以在编写配置文件时任意引用,使得编写 Nginx 配置文件更像编写程序(但注意不要与编程语言里的变量概念混淆,两者是完全不同的)。
在配置文件里使用变量需要以 “$” 开头,例如 $request_method、$args、$uri 等(这与 Shell 和 Perl 是一样的)。变量的用法很多,例如记录访问日志,设置反向代理的参数,或者传递给 Lua 程序获取各种运行时信息。
$uri:当前请求的 URI,但不包含 “?” 后的参数。
$args:当前请求的参数,及 “?” 后的字符串。
$arg_xxx:当前请求里的某个参数,“arg_” 后就是参数名。
$http_xxx:当前请求里的 xxx 头部对应的值。
$sent_http_xxx:返回给客户端的相应头部对应的值。
$remote_addr:客户端 IP 地址。
如果执行下面的 curl 命令:
$ curl 'http://localhost/index.html?a=1&b=2' -H 'hello: world'
变量对应的值为:
$uri = /index.html
$args = a=1&b=2
$arg_a = 1
$arg_b = 2
$http_hello = world
$sent_http_server = openresty/1.13.6.2
$remote_addr = 127.0.0.1
Nginx 内置的变量非常多,详细的列表可以参考官方文档。此外,Nginx 也允许使用指令自定义变量,最常用的就是 Set,例如:
set $max_size 10000; # 定义变量 $max_size="10000"
OpenResty 组件管理工具
很多开发语言/环境都会提供配套的包管理工具,例如 npm/Node.js、cpan/Perl、gem/Ruby 等,它们可以方便地安装功能组件,辅助用户的开发工作,节约用户的时间和经理。OpenResty 也有功能类似的工具,名叫 opm。
OpenResty 维护一个官方组件库(opm.openresty.org),opm 就是库的客户端,可以把组件库里的组件下载到本地,并管理本地的组件列表。
opm 的用法很简单,常用的命令有:
search:以关键字搜索关键的组件。
get:安装功能组件(注意不是 install)。
info:显示已安装组件的详细信息。
list:列出所有本地已经安装的组件。
upgrad:更新某个已安装组件。
update:更新所有已安装组件。
remove:移除某个已安装组件。
opm 默认的操作目录是 “/usr/local/openresty/site”,但是也可以在命令行参数 “--install-dir=PATH” 安装到其他目录,或者用参数 “–cwd” 安装到当前目录的 "./resty_module/" 目录里。
下面的命令示范了 opm 的部分用法:
# 搜索关键字 http
$ opm search http
openresty/lua-resty-upload Streaming reader and parser for HTTP file uploading based on ngx_lua cosocket
dailymotion/lua-nginx-guard-jwt Map JWT claims values to HTTP Headers request. Could specify a custom mapping.
mycsj/lua-resty-rx-test Yet Another HTTP library for OpenResty
tokers/lua-resty-requests Yet Another HTTP library for OpenResty
bungle/lua-resty-reqargs HTTP Request Arguments and File Uploads Helper
fffonion/lua-resty-shdict-server A HTTP and Redis protocol compatible interface for debugging ngx.shared API
hamishforbes/lua-resty-consul Library to interface with the consul HTTP API
hamishforbes/ledge An RFC compliant and ESI capable HTTP cache for Nginx / OpenResty, backed by Redis
lilien1010/lua-resty-s3uploader an http s3 client for openresty
antonheryanto/lua-resty-post Openresty utility for parsing HTTP POST data
duhoobo/lua-resty-smtp A http to smtp bridge library for the ngx_lua module
duhoobo/lua-resty-auth A Lua resty module for HTTP Authentication (both basic and digest scheme supported, referring to RFC 2617)
p0pr0ck5/lua-resty-cookie Lua library for HTTP cookie manipulations for OpenResty/ngx_lua
pintsized/lua-resty-http Lua HTTP client cosocket driver for OpenResty/ngx_lua
agentzh/lua-resty-http Lua HTTP client cosocket driver for OpenResty/ngx_lua
# 搜索关键字 kafka
$ opm search kafka
doujiang24/lua-resty-kafka Lua kafka client driver for the Openresty based on the cosocket API
# 安装组件,注意需要 sudo
$ opm get agentzh/lua-resty-http
* Fetching agentzh/lua-resty-http
Downloading https://opm.openresty.org/api/pkg/tarball/agentzh/lua-resty-http-0.09.opm.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 16385 100 16385 0 0 39111 0 --:--:-- --:--:-- --:--:-- 39105
Package agentzh/lua-resty-http 0.09 installed successfully under /usr/local/openresty/site/ .
# 显示组件的版本,作者等信息。
$ opm info agentzh/lua-resty-http
Name : lua-resty-http
Version : 0.09
Abstract : Lua HTTP client cosocket driver for OpenResty/ngx_lua
Author : James Hurst
Account : agentzh
Code Repo : https://github.com/agentzh/lua-resty-http/tree/agentzh
License : BSD 2-Clause "Simplified" or "FreeBSD" license
Original Work : no
# 移除组件,同样需要 sudo
$ opm remove agentzh/lua-resty-http
Package agentzh/lua-resty-http 0.09 removed successfully.
安装组件:
$ opm --install-dir=/opt get xxx
$ opm --cwd get xxx
需要注意的是 opm 里组件的名字,使用的是类似 GitHub 的格式,即 “作者名/组件名”,允许一个组件有多个不同的作者和版本,方便组件开发者 “百家争鸣”,由客户来评估决定使用哪一个。
由于 opm 在 OpenResty 里出现的较晚(2016年),目前库里可用的组件还不多,希望假以时日能够丰富壮大。
openresty目录结构
openresty/
├── bin
│ ├── md2pod.pl
│ ├── nginx-xml2pod
│ ├── openresty -> /usr/local/openresty/nginx/sbin/nginx
│ ├── opm
│ ├── resty
│ ├── restydoc
│ └── restydoc-index
├── COPYRIGHT
├── luajit
│ ├── bin
│ │ ├── luajit -> luajit-2.1.0-beta3
│ │ └── luajit-2.1.0-beta3
│ ├── include
│ │ └── luajit-2.1
│ │ ├── lauxlib.h
│ │ ├── luaconf.h
│ │ ├── lua.h
│ │ ├── lua.hpp
│ │ ├── luajit.h
│ │ └── lualib.h
│ ├── lib
│ │ ├── libluajit-5.1.so -> libluajit-5.1.so.2.1.0
│ │ ├── libluajit-5.1.so.2 -> libluajit-5.1.so.2.1.0
│ │ ├── libluajit-5.1.so.2.1.0
│ │ ├── lua
│ │ │ └── 5.1
│ │ └── pkgconfig
│ │ └── luajit.pc
│ └── share
│ ├── lua
│ │ └── 5.1
│ └── luajit-2.1.0-beta3
│ └── jit
│ ├── bc.lua
│ ├── bcsave.lua
│ ├── dis_arm64be.lua
│ ├── dis_arm64.lua
│ ├── dis_arm.lua
│ ├── dis_mips64el.lua
│ ├── dis_mips64.lua
│ ├── dis_mipsel.lua
│ ├── dis_mips.lua
│ ├── dis_ppc.lua
│ ├── dis_x64.lua
│ ├── dis_x86.lua
│ ├── dump.lua
│ ├── p.lua
│ ├── v.lua
│ ├── vmdef.lua
│ └── zone.lua
├── lualib
│ ├── cjson.so
│ ├── librestysignal.so
│ ├── ngx
│ │ ├── balancer.lua
│ │ ├── base64.lua
│ │ ├── errlog.lua
│ │ ├── ocsp.lua
│ │ ├── pipe.lua
│ │ ├── process.lua
│ │ ├── re.lua
│ │ ├── req.lua
│ │ ├── resp.lua
│ │ ├── semaphore.lua
│ │ ├── ssl
│ │ │ ├── clienthello.lua
│ │ │ └── session.lua
│ │ └── ssl.lua
│ ├── redis
│ │ └── parser.so
│ ├── resty
│ │ ├── aes.lua
│ │ ├── core
│ │ │ ├── base64.lua
│ │ │ ├── base.lua
│ │ │ ├── ctx.lua
│ │ │ ├── exit.lua
│ │ │ ├── hash.lua
│ │ │ ├── misc.lua
│ │ │ ├── ndk.lua
│ │ │ ├── phase.lua
│ │ │ ├── regex.lua
│ │ │ ├── request.lua
│ │ │ ├── response.lua
│ │ │ ├── shdict.lua
│ │ │ ├── socket.lua
│ │ │ ├── time.lua
│ │ │ ├── uri.lua
│ │ │ ├── utils.lua
│ │ │ ├── var.lua
│ │ │ └── worker.lua
│ │ ├── core.lua
│ │ ├── dns
│ │ │ └── resolver.lua
│ │ ├── limit
│ │ │ ├── conn.lua
│ │ │ ├── count.lua
│ │ │ ├── req.lua
│ │ │ └── traffic.lua
│ │ ├── lock.lua
│ │ ├── lrucache
│ │ │ └── pureffi.lua
│ │ ├── lrucache.lua
│ │ ├── md5.lua
│ │ ├── memcached.lua
│ │ ├── mysql.lua
│ │ ├── random.lua
│ │ ├── redis.lua
│ │ ├── sha1.lua
│ │ ├── sha224.lua
│ │ ├── sha256.lua
│ │ ├── sha384.lua
│ │ ├── sha512.lua
│ │ ├── sha.lua
│ │ ├── shell.lua
│ │ ├── signal.lua
│ │ ├── string.lua
│ │ ├── upload.lua
│ │ ├── upstream
│ │ │ └── healthcheck.lua
│ │ └── websocket
│ │ ├── client.lua
│ │ ├── protocol.lua
│ │ └── server.lua
│ └── tablepool.lua
├── nginx
│ ├── client_body_temp
│ ├── conf
│ │ ├── fastcgi.conf
│ │ ├── fastcgi.conf.default
│ │ ├── fastcgi_params
│ │ ├── fastcgi_params.default
│ │ ├── koi-utf
│ │ ├── koi-win
│ │ ├── lua
│ │ │ ├── test.lua
│ │ │ └── zx.lua
│ │ ├── mime.types
│ │ ├── mime.types.default
│ │ ├── nginx.conf
│ │ ├── nginx.conf.default
│ │ ├── scgi_params
│ │ ├── scgi_params.default
│ │ ├── uwsgi_params
│ │ ├── uwsgi_params.default
│ │ └── win-utf
│ ├── fastcgi_temp
│ ├── html
│ │ ├── 50x.html
│ │ └── index.html
│ ├── logs
│ │ ├── access.log
│ │ ├── error.log
│ │ └── nginx.pid
│ ├── proxy_temp
│ ├── sbin
│ │ ├── bak_nginx
│ │ └── nginx
│ ├── scgi_temp
│ └── uwsgi_temp
├── openssl111
│ ├── bin
│ │ └── openssl
│ └── lib
│ ├── engines-1.1
│ │ ├── capi.so
│ │ └── padlock.so
│ ├── libcrypto.so -> libcrypto.so.1.1
│ ├── libcrypto.so.1.1
│ ├── libssl.so -> libssl.so.1.1
│ └── libssl.so.1.1
├── pcre
│ └── lib
│ ├── libpcre.so -> libpcre.so.1.2.13
│ ├── libpcre.so.1 -> libpcre.so.1.2.13
│ └── libpcre.so.1.2.13
├── pod
│ ├── array-var-nginx-module-0.05
│ │ └── array-var-nginx-module-0.05.pod
│ ├── drizzle-nginx-module-0.1.11
│ │ └── drizzle-nginx-module-0.1.11.pod
│ ├── echo-nginx-module-0.62
│ │ └── echo-nginx-module-0.62.pod
│ ├── encrypted-session-nginx-module-0.09
│ │ └── encrypted-session-nginx-module-0.09.pod
│ ├── form-input-nginx-module-0.12
│ │ └── form-input-nginx-module-0.12.pod
│ ├── headers-more-nginx-module-0.33
│ │ └── headers-more-nginx-module-0.33.pod
│ ├── iconv-nginx-module-0.14
│ │ └── iconv-nginx-module-0.14.pod
│ ├── lua-5.1.5
│ │ └── lua-5.1.5.pod
│ ├── lua-cjson-2.1.0.10
│ │ └── lua-cjson-2.1.0.10.pod
│ ├── luajit-2.1
│ │ ├── changes.pod
│ │ ├── contact.pod
│ │ ├── ext_c_api.pod
│ │ ├── extensions.pod
│ │ ├── ext_ffi_api.pod
│ │ ├── ext_ffi.pod
│ │ ├── ext_ffi_semantics.pod
│ │ ├── ext_ffi_tutorial.pod
│ │ ├── ext_jit.pod
│ │ ├── ext_profiler.pod
│ │ ├── faq.pod
│ │ ├── install.pod
│ │ ├── luajit-2.1.pod
│ │ ├── running.pod
│ │ └── status.pod
│ ├── luajit-2.1-20220411
│ │ └── luajit-2.1-20220411.pod
│ ├── lua-rds-parser-0.06
│ ├── lua-redis-parser-0.13
│ │ └── lua-redis-parser-0.13.pod
│ ├── lua-resty-core-0.1.23
│ │ ├── lua-resty-core-0.1.23.pod
│ │ ├── ngx.balancer.pod
│ │ ├── ngx.base64.pod
│ │ ├── ngx.errlog.pod
│ │ ├── ngx.ocsp.pod
│ │ ├── ngx.pipe.pod
│ │ ├── ngx.process.pod
│ │ ├── ngx.re.pod
│ │ ├── ngx.req.pod
│ │ ├── ngx.resp.pod
│ │ ├── ngx.semaphore.pod
│ │ ├── ngx.ssl.clienthello.pod
│ │ ├── ngx.ssl.pod
│ │ └── ngx.ssl.session.pod
│ ├── lua-resty-dns-0.22
│ │ └── lua-resty-dns-0.22.pod
│ ├── lua-resty-limit-traffic-0.08
│ │ ├── lua-resty-limit-traffic-0.08.pod
│ │ ├── resty.limit.conn.pod
│ │ ├── resty.limit.count.pod
│ │ ├── resty.limit.req.pod
│ │ └── resty.limit.traffic.pod
│ ├── lua-resty-lock-0.08
│ │ └── lua-resty-lock-0.08.pod
│ ├── lua-resty-lrucache-0.11
│ │ └── lua-resty-lrucache-0.11.pod
│ ├── lua-resty-memcached-0.16
│ │ └── lua-resty-memcached-0.16.pod
│ ├── lua-resty-mysql-0.25
│ │ └── lua-resty-mysql-0.25.pod
│ ├── lua-resty-redis-0.30
│ │ └── lua-resty-redis-0.30.pod
│ ├── lua-resty-shell-0.03
│ │ └── lua-resty-shell-0.03.pod
│ ├── lua-resty-signal-0.03
│ │ └── lua-resty-signal-0.03.pod
│ ├── lua-resty-string-0.15
│ │ └── lua-resty-string-0.15.pod
│ ├── lua-resty-upload-0.10
│ │ └── lua-resty-upload-0.10.pod
│ ├── lua-resty-upstream-healthcheck-0.06
│ │ └── lua-resty-upstream-healthcheck-0.06.pod
│ ├── lua-resty-websocket-0.09
│ │ └── lua-resty-websocket-0.09.pod
│ ├── lua-tablepool-0.02
│ │ └── lua-tablepool-0.02.pod
│ ├── memc-nginx-module-0.19
│ │ └── memc-nginx-module-0.19.pod
│ ├── nginx
│ │ ├── accept_failed.pod
│ │ ├── beginners_guide.pod
│ │ ├── chunked_encoding_from_backend.pod
│ │ ├── configure.pod
│ │ ├── configuring_https_servers.pod
│ │ ├── contributing_changes.pod
│ │ ├── control.pod
│ │ ├── converting_rewrite_rules.pod
│ │ ├── daemon_master_process_off.pod
│ │ ├── debugging_log.pod
│ │ ├── development_guide.pod
│ │ ├── events.pod
│ │ ├── example.pod
│ │ ├── faq.pod
│ │ ├── freebsd_tuning.pod
│ │ ├── hash.pod
│ │ ├── howto_build_on_win32.pod
│ │ ├── install.pod
│ │ ├── license_copyright.pod
│ │ ├── load_balancing.pod
│ │ ├── nginx_dtrace_pid_provider.pod
│ │ ├── nginx.pod
│ │ ├── ngx_core_module.pod
│ │ ├── ngx_google_perftools_module.pod
│ │ ├── ngx_http_access_module.pod
│ │ ├── ngx_http_addition_module.pod
│ │ ├── ngx_http_api_module_head.pod
│ │ ├── ngx_http_auth_basic_module.pod
│ │ ├── ngx_http_auth_jwt_module.pod
│ │ ├── ngx_http_auth_request_module.pod
│ │ ├── ngx_http_autoindex_module.pod
│ │ ├── ngx_http_browser_module.pod
│ │ ├── ngx_http_charset_module.pod
│ │ ├── ngx_http_core_module.pod
│ │ ├── ngx_http_dav_module.pod
│ │ ├── ngx_http_empty_gif_module.pod
│ │ ├── ngx_http_f4f_module.pod
│ │ ├── ngx_http_fastcgi_module.pod
│ │ ├── ngx_http_flv_module.pod
│ │ ├── ngx_http_geoip_module.pod
│ │ ├── ngx_http_geo_module.pod
│ │ ├── ngx_http_grpc_module.pod
│ │ ├── ngx_http_gunzip_module.pod
│ │ ├── ngx_http_gzip_module.pod
│ │ ├── ngx_http_gzip_static_module.pod
│ │ ├── ngx_http_headers_module.pod
│ │ ├── ngx_http_hls_module.pod
│ │ ├── ngx_http_image_filter_module.pod
│ │ ├── ngx_http_index_module.pod
│ │ ├── ngx_http_js_module.pod
│ │ ├── ngx_http_keyval_module.pod
│ │ ├── ngx_http_limit_conn_module.pod
│ │ ├── ngx_http_limit_req_module.pod
│ │ ├── ngx_http_log_module.pod
│ │ ├── ngx_http_map_module.pod
│ │ ├── ngx_http_memcached_module.pod
│ │ ├── ngx_http_mirror_module.pod
│ │ ├── ngx_http_mp4_module.pod
│ │ ├── ngx_http_perl_module.pod
│ │ ├── ngx_http_proxy_module.pod
│ │ ├── ngx_http_random_index_module.pod
│ │ ├── ngx_http_realip_module.pod
│ │ ├── ngx_http_referer_module.pod
│ │ ├── ngx_http_rewrite_module.pod
│ │ ├── ngx_http_scgi_module.pod
│ │ ├── ngx_http_secure_link_module.pod
│ │ ├── ngx_http_session_log_module.pod
│ │ ├── ngx_http_slice_module.pod
│ │ ├── ngx_http_spdy_module.pod
│ │ ├── ngx_http_split_clients_module.pod
│ │ ├── ngx_http_ssi_module.pod
│ │ ├── ngx_http_ssl_module.pod
│ │ ├── ngx_http_status_module.pod
│ │ ├── ngx_http_stub_status_module.pod
│ │ ├── ngx_http_sub_module.pod
│ │ ├── ngx_http_upstream_conf_module.pod
│ │ ├── ngx_http_upstream_hc_module.pod
│ │ ├── ngx_http_upstream_module.pod
│ │ ├── ngx_http_userid_module.pod
│ │ ├── ngx_http_uwsgi_module.pod
│ │ ├── ngx_http_v2_module.pod
│ │ ├── ngx_http_xslt_module.pod
│ │ ├── ngx_mail_auth_http_module.pod
│ │ ├── ngx_mail_core_module.pod
│ │ ├── ngx_mail_imap_module.pod
│ │ ├── ngx_mail_pop3_module.pod
│ │ ├── ngx_mail_proxy_module.pod
│ │ ├── ngx_mail_realip_module.pod
│ │ ├── ngx_mail_smtp_module.pod
│ │ ├── ngx_mail_ssl_module.pod
│ │ ├── ngx_stream_access_module.pod
│ │ ├── ngx_stream_core_module.pod
│ │ ├── ngx_stream_geoip_module.pod
│ │ ├── ngx_stream_geo_module.pod
│ │ ├── ngx_stream_js_module.pod
│ │ ├── ngx_stream_keyval_module.pod
│ │ ├── ngx_stream_limit_conn_module.pod
│ │ ├── ngx_stream_log_module.pod
│ │ ├── ngx_stream_map_module.pod
│ │ ├── ngx_stream_proxy_module.pod
│ │ ├── ngx_stream_realip_module.pod
│ │ ├── ngx_stream_return_module.pod
│ │ ├── ngx_stream_set_module.pod
│ │ ├── ngx_stream_split_clients_module.pod
│ │ ├── ngx_stream_ssl_module.pod
│ │ ├── ngx_stream_ssl_preread_module.pod
│ │ ├── ngx_stream_upstream_hc_module.pod
│ │ ├── ngx_stream_upstream_module.pod
│ │ ├── ngx_stream_zone_sync_module.pod
│ │ ├── request_processing.pod
│ │ ├── server_names.pod
│ │ ├── stream_processing.pod
│ │ ├── switches.pod
│ │ ├── syntax.pod
│ │ ├── sys_errlist.pod
│ │ ├── syslog.pod
│ │ ├── variables_in_config.pod
│ │ ├── websocket.pod
│ │ ├── welcome_nginx_facebook.pod
│ │ └── windows.pod
│ ├── ngx_coolkit-0.2
│ ├── ngx_devel_kit-0.3.1
│ │ ├── ngx_devel_kit-0.3.1.pod
│ │ └── readme_auto_lib.pod
│ ├── ngx_lua-0.10.21
│ │ └── ngx_lua-0.10.21.pod
│ ├── ngx_lua_upstream-0.07
│ │ └── ngx_lua_upstream-0.07.pod
│ ├── ngx_postgres-1.0
│ │ ├── ngx_postgres-1.0.pod
│ │ └── todo.pod
│ ├── ngx_stream_lua-0.0.11
│ │ ├── dev_notes.pod
│ │ └── ngx_stream_lua-0.0.11.pod
│ ├── opm-0.0.6
│ │ ├── opm-0.0.6.pod
│ │ └── web.docs.md.docs.pod
│ ├── rds-csv-nginx-module-0.09
│ │ └── rds-csv-nginx-module-0.09.pod
│ ├── rds-json-nginx-module-0.15
│ │ └── rds-json-nginx-module-0.15.pod
│ ├── redis2-nginx-module-0.15
│ │ └── redis2-nginx-module-0.15.pod
│ ├── redis-nginx-module-0.3.9
│ ├── resty-cli-0.28
│ │ └── resty-cli-0.28.pod
│ ├── set-misc-nginx-module-0.33
│ │ └── set-misc-nginx-module-0.33.pod
│ ├── srcache-nginx-module-0.32
│ │ └── srcache-nginx-module-0.32.pod
│ └── xss-nginx-module-0.06
│ └── xss-nginx-module-0.06.pod
├── resty.index
├── site
│ ├── lualib
│ │ └── resty
│ │ ├── aes.lua
│ │ ├── array.lua
│ │ ├── evp.lua
│ │ ├── hmac.lua
│ │ ├── jwt.lua
│ │ ├── jwt-validators.lua
│ │ ├── md5.lua
│ │ ├── mysql.lua
│ │ ├── object.lua
│ │ ├── random.lua
│ │ ├── set.lua
│ │ ├── sha1.lua
│ │ ├── sha224.lua
│ │ ├── sha256.lua
│ │ ├── sha384.lua
│ │ ├── sha512.lua
│ │ ├── sha.lua
│ │ └── string.lua
│ ├── manifest
│ │ ├── lua-resty-array.list
│ │ ├── lua-resty-array.meta
│ │ ├── lua-resty-hmac.list
│ │ ├── lua-resty-hmac.meta
│ │ ├── lua-resty-jwt.list
│ │ ├── lua-resty-jwt.meta
│ │ ├── lua-resty-mysql.list
│ │ ├── lua-resty-mysql.meta
│ │ ├── lua-resty-object.list
│ │ ├── lua-resty-object.meta
│ │ ├── lua-resty-set.list
│ │ ├── lua-resty-set.meta
│ │ ├── lua-resty-string.list
│ │ └── lua-resty-string.meta
│ ├── pod
│ │ ├── lua-resty-array-1.0
│ │ │ └── lua-resty-array-1.0.pod
│ │ ├── lua-resty-hmac-0.06
│ │ │ └── lua-resty-hmac-0.06.pod
│ │ ├── lua-resty-jwt-0.2.3
│ │ │ └── lua-resty-jwt-0.2.3.pod
│ │ ├── lua-resty-mysql-0.22
│ │ │ └── lua-resty-mysql-0.22.pod
│ │ ├── lua-resty-object-1.2
│ │ │ └── lua-resty-object-1.2.pod
│ │ ├── lua-resty-set-1.21
│ │ │ └── lua-resty-set-1.21.pod
│ │ └── lua-resty-string-0.11
│ │ └── lua-resty-string-0.11.pod
│ └── resty.index
└── zlib
└── lib
├── libz.so -> libz.so.1.2.12
├── libz.so.1 -> libz.so.1.2.12
└── libz.so.1.2.12
102 directories, 375 files
设置package包的搜索路径
package.path = '/usr/local/share/lua/5.1/?.lua;/usr/local/openresty/lualib/resty/?.lua;/usr/local/openresty/lualib/?.lua;'
package.cpath = '/usr/local/lib/lua/5.1/?.so;'
local cjson = require "cjson"
lua_package_path "lua/?.lua;app/?.lua";
lua_code_cache off;
-- 打印目前的包搜索的路径
ngx.say(package.path)
打印结果
/usr/local/openresty/site/lualib/?.ljbc;/usr/local/openresty/site/lualib/?/init.ljbc;/usr/local/openresty/lualib/?.ljbc;/usr/local/openresty/lualib/?/init.ljbc;/usr/local/openresty/site/lualib/?.lua;/usr/local/openresty/site/lualib/?/init.lua;/usr/local/openresty/lualib/?.lua;/usr/local/openresty/lualib/?/init.lua;./?.lua;/usr/local/openresty/luajit/share/luajit-2.1.0-beta3/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/usr/local/openresty/luajit/share/lua/5.1/?.lua;/usr/local/openresty/luajit/share/lua/5.1/?/init.lua
把prel的 pod文档文件转成html
C:\Strawberry\perl\bin> .\pod2html.bat D:\openresty\pod\lua-5.1.5\lua-5.1.5.pod > D:\openresty\pod\lua-5.1.5\lua-5.1.5.html
可以直接转成html