Skip to content

Instantly share code, notes, and snippets.

@therealssj
Created May 31, 2018 23:36
Show Gist options
  • Save therealssj/b71414d01e0a8985b0810657104f5e34 to your computer and use it in GitHub Desktop.
Save therealssj/b71414d01e0a8985b0810657104f5e34 to your computer and use it in GitHub Desktop.
install nginx with lua support
#!/bin/sh
# Script to compile nginx on ubuntu with lua support.
NGX_VERSION='1.13.1'
LUAJIT_VERSION='2.0.5'
LUAJIT_MAJOR_VERSION='2.0'
NGX_DEVEL_KIT_VERSION='0.3.0'
LUA_NGINX_MODULE_VERSION='0.10.9rc6'
NGINX_INSTALL_PATH='/usr/local/nginx'
# Download
if [ ! -f ./nginx-${NGX_VERSION}.tar.gz ]; then
wget http://nginx.org/download/nginx-${NGX_VERSION}.tar.gz
fi
if [ ! -f ./LuaJIT-${LUAJIT_VERSION}.tar.gz ]; then
wget http://luajit.org/download/LuaJIT-${LUAJIT_VERSION}.tar.gz
fi
if [ ! -f ./ngx_devel_kit-${NGX_DEVEL_KIT_VERSION}.tar.gz ]; then
wget https://github.com/simpl/ngx_devel_kit/archive/v${NGX_DEVEL_KIT_VERSION}.tar.gz \
-O ngx_devel_kit-${NGX_DEVEL_KIT_VERSION}.tar.gz
fi
if [ ! -f ./lua-nginx-module-${LUA_NGINX_MODULE_VERSION}.tar.gz ]; then
wget https://github.com/openresty/lua-nginx-module/archive/v${LUA_NGINX_MODULE_VERSION}.tar.gz \
-O lua-nginx-module-${LUA_NGINX_MODULE_VERSION}.tar.gz
fi
# Extract
if [ ! -d ./nginx-${NGX_VERSION} ]; then
tar xvf nginx-${NGX_VERSION}.tar.gz
fi
if [ ! -d ./LuaJIT-${LUAJIT_VERSION} ]; then
tar xvf LuaJIT-${LUAJIT_VERSION}.tar.gz
fi
if [ ! -d ./lua-nginx-module-${LUA_NGINX_MODULE_VERSION} ]; then
tar xvf lua-nginx-module-${LUA_NGINX_MODULE_VERSION}.tar.gz
fi
if [ ! -d ./ngx_devel_kit-${NGX_DEVEL_KIT_VERSION} ]; then
tar xvf ngx_devel_kit-${NGX_DEVEL_KIT_VERSION}.tar.gz
fi
# Install luajit
cd ./LuaJIT-${LUAJIT_VERSION} && sudo make install && cd ..
NGX_DEVEL_KIT_PATH=$(pwd)/ngx_devel_kit-${NGX_DEVEL_KIT_VERSION}
LUA_NGINX_MODULE_PATH=$(pwd)/lua-nginx-module-${LUA_NGINX_MODULE_VERSION}
# Compile And Install Nginx
cd ./nginx-${NGX_VERSION} && \
LUAJIT_LIB=/usr/local/lib/lua LUAJIT_INC=/usr/local/include/luajit-${LUAJIT_MAJOR_VERSION} \
./configure --prefix=${NGINX_INSTALL_PATH} --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid \
--sbin-path=/usr/sbin/nginx --lock-path=/var/run/nginx.lock \
--with-ld-opt='-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -Wl,-rpath,/usr/local/lib/lua' \
--with-cc-opt='-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' \
--http-client-body-temp-path=/var/lib/nginx/body \
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
--http-scgi-temp-path=/var/lib/nginx/scgi \
--http-uwsgi-temp-path=/var/lib/nginx/uwsgi \
--http-proxy-temp-path=/var/lib/nginx/proxy \
--with-debug \
--with-pcre-jit \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_realip_module \
--with-http_auth_request_module \
--with-http_addition_module \
--with-http_dav_module \
--with-http_geoip_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_image_filter_module \
--with-http_v2_module \
--with-http_xslt_module \
--with-http_sub_module \
--with-stream --with-stream_ssl_module --with-mail --with-mail_ssl_module \
--with-threads \
--with-file-aio \
--add-module=${NGX_DEVEL_KIT_PATH} \
--add-module=${LUA_NGINX_MODULE_PATH} \
&& make -j2 && sudo make install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment