-
-
Save dancingfrog/c06dadc7ea2ebabd47ebc8336d6ac187 to your computer and use it in GitHub Desktop.
THANK YOU FOR MAKING THIS! UPDATE: Assumes nginx source has been already been downloaded to working directory using $ apt-get source nginx
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/sh | |
# Script to compile nginx on ubuntu with lua support. | |
# Assumes that nginx source is already present in current working dir, after running... | |
# | |
# $ apt-get source nginx | |
# | |
# ... and that nginx-<version>/debian/rules has been updated with | |
# the desired options, including those passed to ./configure | |
# | |
# --conf-path=${NGINX_INSTALL_PATH}/nginx.conf --pid-path=/var/run/nginx.pid \ | |
# --sbin-path=/usr/sbin/nginx --lock-path=/var/run/nginx.lock \ | |
# --with-ld-opt='-Wl,-rpath,/usr/local/lib/lua' \ | |
# --add-module=${NGX_DEVEL_KIT_PATH} \ | |
# --add-module=${LUA_NGINX_MODULE_PATH} \ | |
export NGX_VERSION='1.9.15' | |
export LUAJIT_VERSION='2.0.3' | |
export LUAJIT_MAJOR_VERSION='2.0' | |
export NGX_DEVEL_KIT_VERSION='0.2.19' | |
export LUA_NGINX_MODULE_VERSION='0.10.2' | |
# Download | |
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 | |
echo "Error: nginx-${NGX_VERSION} was not downloaded\n" && exit 1; | |
fi | |
if [ ! -d ./LuaJIT-${LUAJIT_VERSION} ]; then | |
tar xvf LuaJIT-${LUAJIT_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 | |
if [ ! -d ./lua-nginx-module-${LUA_NGINX_MODULE_VERSION} ]; then | |
tar xvf lua-nginx-module-${LUA_NGINX_MODULE_VERSION}.tar.gz | |
fi | |
export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:/usr/local/lib/:$LD_LIBRARY_PATH | |
ldconfig | |
# Install luajit | |
cd ./LuaJIT-${LUAJIT_VERSION} && sudo make install && cd ../ | |
# Link to real lua lib | |
rm -rf /usr/local/lib/lua/5.1 && ln -s /usr/lib/x86_64-linux-gnu/lua/5.1 /usr/local/lib/lua/5.1 | |
export NGX_DEVEL_KIT_PATH=../ngx_devel_kit-${NGX_DEVEL_KIT_VERSION} | |
export LUA_NGINX_MODULE_PATH=../lua-nginx-module-${LUA_NGINX_MODULE_VERSION} | |
# Compile And Install Nginx | |
cd ./nginx-${NGX_VERSION} && \ | |
export LUAJIT_LIB=/usr/local/lib/lua && \ | |
export LUAJIT_INC=/usr/local/include/luajit-${LUAJIT_MAJOR_VERSION} && \ | |
dpkg-buildpackage -b && cd ../ | |
dpkg --install nginx*${NGX_VERSION}-*.deb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment