Created
July 28, 2016 10:40
-
-
Save ikennaokpala/4e2508c30f4aa301cbbe5355212d2c69 to your computer and use it in GitHub Desktop.
install nginx with ngx_lua automatically under debian/ubuntu like system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
NGX_VER="1.8.0" | |
NDK_VER="0.2.19" | |
NGX_LUA_VER="0.9.16" | |
LUAJIT_VER="2.0.4" | |
LUAROCKS_VER="2.2.1" | |
WORKDIR=$(pwd) | |
NGX_INSTALL_DIR="/usr/local/nginx" | |
if ! [ -e "nginx-${NGX_VER}.tar.gz" ]; then | |
wget http://nginx.org/download/nginx-${NGX_VER}.tar.gz | |
fi | |
if ! [ -e "v${NDK_VER}.tar.gz" ]; then | |
wget https://github.com/simpl/ngx_devel_kit/archive/v${NDK_VER}.tar.gz | |
fi | |
if ! [ -e "v${NGX_LUA_VER}.tar.gz" ]; then | |
wget https://github.com/openresty/lua-nginx-module/archive/v${NGX_LUA_VER}.tar.gz | |
fi | |
if ! [ -e "LuaJIT-${LUAJIT_VER}.tar.gz" ]; then | |
wget http://luajit.org/download/LuaJIT-${LUAJIT_VER}.tar.gz | |
fi | |
if ! [ -e "luarocks-${LUAROCKS_VER}.tar.gz" ]; then | |
wget http://luarocks.org/releases/luarocks-2.2.1.tar.gz | |
fi | |
install_luarocks() { | |
cd $WORKDIR | |
tar zxpf luarocks-${LUAROCKS_VER}.tar.gz | |
cd luarocks-${LUAROCKS_VER} | |
./configure --lua-suffix=jit --with-lua-include=/usr/local/include/luajit-2.0 | |
sudo make bootstrap | |
} | |
extract_ndk() { | |
if ! [ -d ${WORKDIR}/ngx_devel_kit-${NDK_VER} ]; then | |
tar zxf v${NDK_VER}.tar.gz | |
fi | |
} | |
extract_lua_ngx() { | |
if ! [ -d ${WORKDIR}/lua-nginx-module-${NGX_LUA_VER} ]; then | |
tar zxf v${NGX_LUA_VER}.tar.gz | |
fi | |
} | |
install_luajit() { | |
cd $WORKDIR | |
tar zxf LuaJIT-${LUAJIT_VER}.tar.gz | |
cd LuaJIT-${LUAJIT_VER} | |
make | |
sudo make install | |
} | |
extract_nginx() { | |
if ! [ -d "$WORKDIR/nginx-${NGX_VER}" ]; then | |
tar zxf nginx-${NGX_VER}.tar.gz | |
fi | |
} | |
install_nginx() { | |
cd "$WORKDIR/nginx-${NGX_VER}" | |
export LUAJIT_LIB=/usr/local/lib | |
export LUAJIT_INC=/usr/local/include/luajit-2.0 | |
./configure --prefix=${NGX_INSTALL_DIR} --with-ld-opt='-Wl,-rpath,/usr/local/lib' --add-module=${WORKDIR}/ngx_devel_kit-${NDK_VER} --add-module=${WORKDIR}/lua-nginx-module-${NGX_LUA_VER} | |
make -j2 | |
sudo make install | |
sudo ln -sf /usr/local/nginx/sbin/nginx /usr/local/bin | |
} | |
sudo apt-get update | |
sudo apt-get install -yy build-essential make libpcre3-dev zlibc zlib1g-dev | |
extract_ndk | |
extract_nginx | |
extract_lua_ngx | |
if [ -z `command -v luajit` ]; then | |
install_luajit | |
fi | |
if [ -z `command -v nginx`]; then | |
install_nginx | |
fi | |
if [ -z `command -v luarocks` ]; then | |
install_luarocks | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think last line on
install_nginx()
have to besudo ln -sf ${NGX_INSTALL_DIR}/sbin/nginx /usr/local/bin
It's true?