Skip to content

Instantly share code, notes, and snippets.

@clecidor
Created October 14, 2014 20:16
Show Gist options
  • Save clecidor/bbf9e7130ab0ba2f16d6 to your computer and use it in GitHub Desktop.
Save clecidor/bbf9e7130ab0ba2f16d6 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# bash < <(curl -s https://gist.github.com/jmervine/5407622/raw/nginx_w_lua.bash)
# Adapted from http://mervine.net/nginx-with-lua-module
# REQUIREMENT - uncomment if PCRE library is not already installed
# apt-get install libpcre3 libpcre3-dev
set -x
cd /tmp
if ! test -d /usr/local/include/luajit-2.0; then
echo "Installing LuaJIT-2.0.1."
wget "http://luajit.org/download/LuaJIT-2.0.2.tar.gz"
tar -xzvf LuaJIT-2.0.2.tar.gz
cd LuaJIT-2.0.2
make
sudo make install
else
echo "Skipping LuaJIT-2.0.1, as it's already installed."
fi
mkdir ngx_devel_kit
cd ngx_devel_kit
wget "https://github.com/simpl/ngx_devel_kit/archive/v0.2.19.tar.gz"
tar -xzvf v0.2.19.tar.gz
NGX_DEV="/tmp/ngx_devel_kit/ngx_devel_kit-0.2.19"
cd /tmp
mkdir lua-nginx-module
cd lua-nginx-module
#wget "https://github.com/chaoslawful/lua-nginx-module/archive/v0.7.21.tar.gz"
wget "https://github.com/openresty/lua-nginx-module/archive/v0.9.12.tar.gz"
tar -xzvf v0.9.12.tar.gz
LUA_MOD="/tmp/lua-nginx-module/lua-nginx-module-0.9.12"
cd /tmp
wget 'http://nginx.org/download/nginx-1.7.4.tar.gz'
tar -xzvf nginx-1.7.4.tar.gz
cd ./nginx-1.7.4
export LUAJIT_LIB=/usr/local/lib
export LUAJIT_INC=/usr/local/include/luajit-2.0
./configure --prefix=/opt/nginx \
--add-module=$NGX_DEV \
--add-module=$LUA_MOD
make -j2
sudo make install
unset LUAJIT_LIB
unset LUAJIT_INC
@abhishekgnanda
Copy link

Line 24 needs "cd /tmp" before the mkdir. I noticed this when I had to run the script twice each time because it complained that it cannot find "/tmp/ngx_devel_kit/ngx_devel_kit-0.2.19/config"

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