OpenResty
首先安装PCRE,这里使用Homebrew来安装,执行如下命令:
brew update
brew install pcre openssl
之后到openresty官网下载源码包 https://openresty.org/cn/download.html
解压,编译,安装
tar -xzvf openresty-VERSION.tar.gz
cd openresty-VERSION/
./configure
make
make install
至此,openresty就安装成功了。
启动openresty:
openresty-VERSION/nginx/sbin/nginx
平滑重启openresty:
openresty-VERSION/nginx/sbin/nginx -s reload
在openresty-VERSION/nginx/目录下创建/lua文件夹,打开lua文件夹,创建on_init.lua文件,输入以下内容:
如图:
ngx打印error级别日志
ngx.log(ngx.ERR, "Hello World!");
在openresty-VERSION/nginx/conf/目录下创建lua.conf,加入如下代码:
init_by_lua_file ./lua/on_init.lua;
打开openresty-VERSION/nginx/conf/nginx.conf,在http大括号内加入 include lua.conf,如下:
http {
####
include lua.conf;
####
}
重启openresty,查看openresty-VERSION/nginx/logs/error.log,可以看到类似如下输出:
[notice] 24130#0: signal process started
[error] 20036#0: [lua] on_init.lua:1: Hello World!
接下来,就可以体验 openresty 啦!
未完待续~~~~
本文暂时没有评论,来添加一个吧(●'◡'●)