openresty

安装

官网

brew install openresty/brew/openresty

安装路径

$ pwd
/opt/homebrew/Cellar/openresty/1.21.4.1_1
$ ll
total 544
drwxr-xr-x   9 zhx  admin   288B  2 14 12:24 bin
-rw-r--r--   1 zhx  admin   583B  2 14 12:24 homebrew.mxcl.openresty.plist
drwxr-xr-x   6 zhx  admin   192B  2 14 12:24 luajit
drwxr-xr-x   9 zhx  admin   288B  2 16 08:46 lualib
drwxr-xr-x   6 zhx  admin   192B  2 14 14:01 nginx
drwxr-xr-x  47 zhx  admin   1.5K  2 14 12:24 pod
-rw-r--r--   1 zhx  admin   230K  2 14 12:24 resty.index
drwxr-xr-x   5 zhx  admin   160B  2 14 12:24 site

bin目录里存放的是openresty可执行文件,关系到openresty的运行,较重要的有:

  • Oopenresty: 可执行文件,用来启动openresty服务
  • opm:组件管理工具,用来安装各种功能组件
  • resty:命令行工具,可直接执行lua程序
  • restydoc: 参考手册

lualib目录存放的是openresty自带的lua组件,如:lua_cjson、lua-core等

启动、停止服务

openresty
opoenresty -s stop

组件管理工具

类似于node的npm,openresty有个opm

opm search kafka
opm get http
opm remove agentzh/lua-resty-http
opm info

# 获取文件上传工具
opm get openresty/lua-resty-upload
* Fetching openresty/lua-resty-upload  
Package openresty/lua-resty-upload 0.10 installed successfully under /opt/homebrew/Cellar/openresty/1.21.4.1_1/site/ .

ls /opt/homebrew/Cellar/openresty/1.21.4.1_1/site/lualib/resty/
upload.lua

命令行工具

resty -e "print('hello world')"

运行脚本文件

demo.lua

#! /usr/bin/env resty

print('hello lua')
chmod +x demo.lua
./demo.lua
posted @ 2023-02-21 17:23  fight139  阅读(169)  评论(0)    收藏  举报