Skip to content

Instantly share code, notes, and snippets.

@nijikokun
Last active October 7, 2016 01:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nijikokun/09e5c8d4f567c3a74330119d3de53895 to your computer and use it in GitHub Desktop.
Save nijikokun/09e5c8d4f567c3a74330119d3de53895 to your computer and use it in GitHub Desktop.
Easily install Kong dependencies for building source on OS X / macOS

I wrote this after having built Kong from scratch and having to remove / reverse engineer some brew packages.

Note this will remove your current environment and build a new one.

Note #2 This does not install OpenSSL, I used brew to install it instead.

LUAROCKS_VERSION=2.3.0
OPENRESTY_VERSION=1.11.2.1
SERF_VERSION=0.7.0
rm /usr/local/bin/serf
rm -rf /usr/local/share/lua
rm -rf /usr/local/openresty
# Configure & Install OpenResty
curl -L https://openresty.org/download/openresty-$OPENRESTY_VERSION.tar.gz | tar xz
cd openresty-$OPENRESTY_VERSION
./configure \
--with-cc-opt="-I/usr/local/opt/openssl/include/ -I/usr/local/opt/pcre/include/" \
--with-ld-opt="-L/usr/local/opt/openssl/lib/ -L/usr/local/opt/pcre/lib/" \
--with-pcre-jit \
--with-ipv6 \
--with-http_realip_module \
--with-http_ssl_module \
--with-http_stub_status_module \
-j8
make
make install
cd ..
# Cleanup OpenResty
rm -rf openresty-$OPENRESTY_VERSION
# Fetch Luarocks & Build
git clone https://github.com/keplerproject/luarocks.git luarocks
cd luarocks
git checkout v$LUAROCKS_VERSION
./configure \
--prefix=/usr/local \
--lua-suffix=jit \
--with-lua=/usr/local/openresty/luajit \
--with-lua-include=/usr/local/openresty/luajit/include/luajit-2.1
make build
make install
cd ..
# Cleanup Luarocks
rm -rf luarocks
# Fetch Serf & Install
wget https://releases.hashicorp.com/serf/$SERF_VERSION/serf_$SERF_VERSION_darwin_amd64.zip
unzip serf_$SERF_VERSION_darwin_amd64.zip
mv serf /usr/local/bin
# Cleanup Serf
rm -rf serf_$SERF_VERSION_darwin_amd64.zip
# Versions & Other Things
echo "Completed."
echo " "
echo "Make sure to add OpenResty binary folders to your PATH:"
echo " "
echo " openresty: /usr/local/openresty/bin"
echo " nginx: /usr/local/openresty/nginx/sbin"
echo " "
echo "Program versions & Details:"
which /usr/local/openresty/nginx/sbin/nginx
/usr/local/openresty/nginx/sbin/nginx -V
which /usr/local/openresty/bin/resty
/usr/local/openresty/bin/resty -V
which luarocks
luarocks --version
which serf
serf version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment