Skip to content

Instantly share code, notes, and snippets.

@knubie
Last active August 29, 2015 14:07
Show Gist options
  • Save knubie/57b10132fb73d52414ad to your computer and use it in GitHub Desktop.
Save knubie/57b10132fb73d52414ad to your computer and use it in GitHub Desktop.

Installing Lapis

Installing Openresty

Add the homebrew/nginx tap.

$ brew tap homebrew/nginx

Install openresty from homebrew.

$ brew install openresty

Installing Lapis

Install the LuaRocks package manager.

$ brew install luarocks

Install Lapis.

$ luarocks install lapis

Install Moonscript (optional).

$ luarocks install moonscript

Running Lapis

Lapis looks for the Openresty nginx binary in these locations:

"/usr/local/openresty/nginx/sbin/"
"/usr/local/opt/openresty/bin/"
"/usr/sbin/"
""

But the homebrew Openresty nginx binary is called openresty, not nginx. To tell Lapis where to look for the Openresty nginx binary we can set the LAPIS_OPENRESTY environment variable to the nginx path; which openresty, and then run the server with lapis server.

LAPIS_OPENRESTY=$(which openresty) lapis server

Another caveat

Openresty requires lua 5.1 not 5.2

Running with vagrant/docker

Because docker uses linux container which aren't available on OS X we'll need to run docker inside of a linux virtual machine. Docker provides a Boot2Docker app for this reason, but we'll use Vagrant instead.

Vagrantfile:

Vagrant.configure("2") do |config|
  config.vm.provider "docker" do |d|
    d.image = "jchaney/openresty-nginx"
  end
	config.vm.network "public_network"
	config.vm.provision "shell", inline: "lapis server production"
end

Docker needs a process to run, otherwise it will imediately exit.

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