brew install openresty/brew/openresty
mac 经过brew install nginx 安装nginx时,实际上是不包含lua模块的。
固然为了使用lua,你能够本身编译该模块。html
而我使用的是上面的安装openresty的方法,能够将它当作nginx和lua的结合体nginx
能够使用下面两种方法启动nginx
1.sudo openresty
2.sudo nginx (须要把/usr/local/Cellar/openresty/1.11.2.5/nginx/sbin添加到PATH里)测试
能够经过在/usr/local/etc/openresty/nginx.conf中添加以下代码,判断是否支持lualua
location /lua { default_type 'text/html'; content_by_lua 'ngx.say("hello world");'; }
sudo nginx -t 测试验证没有问题
rest
重启nginx,访问 http://localhost/lua显示hello worldcode