mac安装openresty

 brew install openresty/brew/openresty

mac 通过brew install nginx 安装nginx时,其实是不包含lua模块的。
当然为了使用lua,你可以自己编译该模块。

而我使用的是上面的安装openresty的方法,可以将它看成nginx和lua的结合体

可以使用下面两种方法启动nginx
1.sudo openresty
2.sudo nginx (需要把/usr/local/Cellar/openresty/1.11.2.5/nginx/sbin添加到PATH里)

可以通过在/usr/local/etc/openresty/nginx.conf中添加如下代码,判断是否支持lua

location /lua {
    default_type 'text/html';
    content_by_lua 'ngx.say("hello world");';
}

sudo nginx -t 测试验证没有问题

重启nginx,访问 http://localhost/lua显示hello world

posted @ 2018-08-02 15:54  高疯疯疯  阅读(312)  评论(0编辑  收藏  举报