Skip to content

Instantly share code, notes, and snippets.

@jugyo
Created October 13, 2012 00:16
Show Gist options
  • Save jugyo/3882497 to your computer and use it in GitHub Desktop.
Save jugyo/3882497 to your computer and use it in GitHub Desktop.
nginx + ngx_lua on Mac

Installation

http://wiki.nginx.org/HttpLuaModule#Installation

install LuaJIT

$ brew install luajit

download ngx_devel_kit

$ cd /usr/local/src
$ git clone https://github.com/simpl/ngx_devel_kit.git

download lua-nginx-module

$ cd /usr/local/src
$ git clone https://github.com/chaoslawful/lua-nginx-module.git

add configure options (via brew edit nginx)

--add-module=/usr/local/src/ngx_devel_kit
--add-module=/usr/local/src/lua-nginx-module

compile nginx

$ export LUAJIT_LIB=/usr/local/Cellar/luajit/2.0.0-beta10/lib
$ export LUAJIT_INC=/usr/local/Cellar/luajit/2.0.0-beta10/include/luajit-2.0
$ brew install nginx

Tips

logging

ngx.log(ngx.ERR, "foo")
@muhqu
Copy link

muhqu commented Jan 8, 2015

If you want to use the set_by_lua directive, the ngx_devel_kit module also needs to be installed.

The nginx-full formula already adds this module when the set-misc module should be installed.

brew tap homebrew/nginx
brew install nginx-full --with-lua-module --with-set-misc-module

@JoyJava
Copy link

JoyJava commented Dec 30, 2015

$ brew reinstall nginx-full --with-lua-module --with-set-misc-module
bug Message :

==> Reinstalling homebrew/nginx/nginx-full with --with-lua-module, --with-set-misc-module
Error: wrong number of arguments (0 for 1..3)
Please report this bug:
https://git.io/brew-troubleshooting
/usr/local/Library/Homebrew/software_spec.rb:72:in instance_eval' /usr/local/Library/Homebrew/software_spec.rb:72:inbottle'
/usr/local/Library/Homebrew/formula.rb:1543:in bottle' /usr/local/Library/Taps/homebrew/homebrew-nginx/Formula/ngx-devel-kit.rb:8:inclass:NgxDevelKit'
/usr/local/Library/Taps/homebrew/homebrew-nginx/Formula/ngx-devel-kit.rb:1:in load_formula' /usr/local/Library/Homebrew/formulary.rb:21:inmodule_eval'
/usr/local/Library/Homebrew/formulary.rb:21:in load_formula' /usr/local/Library/Homebrew/formulary.rb:34:inload_formula_from_path'
/usr/local/Library/Homebrew/formulary.rb:83:in load_file' /usr/local/Library/Homebrew/formulary.rb:74:inklass'
/usr/local/Library/Homebrew/formulary.rb:70:in get_formula' /usr/local/Library/Homebrew/formulary.rb:205:infactory'
/usr/local/Library/Homebrew/dependency.rb:32:in to_formula' /usr/local/Library/Homebrew/dependency.rb:88:inblock in expand'
/usr/local/Library/Homebrew/dependencies.rb:9:in each' /usr/local/Library/Homebrew/dependencies.rb:9:ineach'
/usr/local/Library/Homebrew/dependency.rb:76:in expand' /usr/local/Library/Homebrew/dependency.rb:88:inblock in expand'
/usr/local/Library/Homebrew/dependencies.rb:9:in each' /usr/local/Library/Homebrew/dependencies.rb:9:ineach'
/usr/local/Library/Homebrew/dependency.rb:76:in expand' /usr/local/Library/Homebrew/formula.rb:1084:inrecursive_dependencies'
/usr/local/Library/Homebrew/formula_installer.rb:111:in verify_deps_exist' /usr/local/Library/Homebrew/formula_installer.rb:104:inprelude'
/usr/local/Library/Homebrew/cmd/reinstall.rb:30:in reinstall_formula' /usr/local/Library/Homebrew/cmd/reinstall.rb:7:inblock in reinstall'
/usr/local/Library/Homebrew/cmd/reinstall.rb:7:in each' /usr/local/Library/Homebrew/cmd/reinstall.rb:7:inreinstall'

@edwardahaynes
Copy link

JoyJava, update your homebrew -> brew update

@adong
Copy link

adong commented Feb 23, 2017

brew --version
Homebrew 1.1.10
Homebrew/homebrew-core (git revision 697d; last commit 2017-02-22)

Try this for

 brew install homebrew/nginx/nginx-full --with-lua-module --with-set-misc-module

@jeffbondlink
Copy link

Thanks for commenting on an old post @adong, exactly what i needed.

@gingerr
Copy link

gingerr commented Mar 31, 2018

New year, new steps to do it:
brew tap denji/nginx
brew install homebrew/nginx/nginx-full --with-lua-module --with-set-misc-module

https://github.com/denji/homebrew-nginx

@abhijit-paul-blippar
Copy link

Since homebrew/nginx is deprecated, using:

brew tap denji/nginx; 
brew install nginx-full --with-lua-module --with-set-misc-module

worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment