Created
January 5, 2014 23:28
-
-
Save phcostabh/8275546 to your computer and use it in GitHub Desktop.
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 | |
# TODO: Add helpful comments. | |
set -x | |
SRC_DIR="/usr/local/src" | |
NGX_INSTALL_VERSION="1.4.2" | |
LUA_JIT_VERSION="2.0.2" | |
LUA_PATH="/usr/local/include/luajit-2.0" | |
NGX_REQUIREMENTS=( | |
"build-essential" | |
"libpcre3" | |
"libpcre3-dev" | |
"zlib1g" | |
"zlib1g-dev" | |
"openssl" | |
"libssl-dev" | |
"libxml2" | |
"libxml2-dev" | |
"libxslt1" | |
"libxslt1-dev" | |
"libgd-dev" | |
"libgeoip-dev" | |
) | |
for requirement in "${NGX_REQUIREMENTS[@]}"; do | |
dpkg -s "$requirement" &> /dev/null || { | |
apt-get install -f -y "$requirement" | |
} | |
done | |
NGX_MODULES=( | |
"https://github.com/simpl/ngx_devel_kit/archive/v0.2.18.tar.gz" | |
"https://github.com/chaoslawful/lua-nginx-module/archive/v0.8.7.tar.gz" | |
"https://github.com/agentzh/echo-nginx-module/archive/v0.47.tar.gz" | |
"http://github.com/gnosek/nginx-upstream-fair/tarball/master" | |
"https://github.com/agentzh/redis2-nginx-module/archive/v0.10.tar.gz" | |
"https://github.com/agentzh/set-misc-nginx-module/archive/v0.23.tar.gz" | |
) | |
cd $SRC_DIR | |
if ! test -d $SRC_DIR/nginx-$NGX_INSTALL_VERSION; then | |
if ! test -d $LUA_PATH; then | |
wget "http://luajit.org/download/LuaJIT-$LUA_JIT_VERSION.tar.gz" -O - --no-check-certificate | tar -zxf - -C $SRC_DIR | |
cd "$SRC_DIR/LuaJIT-$LUA_JIT_VERSION" | |
make | |
make install | |
fi | |
cd $SRC_DIR | |
NGX_CONFIG_ARGS="--prefix=/etc/nginx | |
--conf-path=/etc/nginx/nginx.conf | |
--error-log-path=/var/log/nginx/error.log | |
--http-client-body-temp-path=/var/lib/nginx/body | |
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi | |
--http-log-path=/var/log/nginx/access.log | |
--http-proxy-temp-path=/var/lib/nginx/proxy | |
--http-scgi-temp-path=/var/lib/nginx/scgi | |
--http-uwsgi-temp-path=/var/lib/nginx/uwsgi | |
--lock-path=/var/lock/nginx.lock | |
--pid-path=/var/run/nginx.pid | |
--with-debug --with-http_addition_module | |
--with-http_dav_module | |
--with-http_geoip_module | |
--with-http_gzip_static_module | |
--with-http_image_filter_module | |
--with-http_realip_module | |
--with-http_stub_status_module | |
--with-http_ssl_module | |
--with-http_sub_module | |
--with-http_xslt_module | |
--with-ipv6 | |
--with-sha1=/usr/include/openssl | |
--with-md5=/usr/include/openssl | |
--with-mail --with-mail_ssl_module | |
--with-http_gunzip_module | |
--with-http_spdy_module | |
--with-http_secure_link_module" | |
NGX_MODULES_PATH="$SRC_DIR/nginx_modules" | |
mkdir -p $NGX_MODULES_PATH &> /dev/null | |
rm -fr "$NGX_MODULES_PATH/*" | |
for module in "${NGX_MODULES[@]}"; do | |
wget "$module" -O - --no-check-certificate | tar -zxf - -C "$NGX_MODULES_PATH" | |
done | |
for module_path in `ls -1 $NGX_MODULES_PATH`; do | |
NGX_CONFIG_ARGS+=" --add-module=$NGX_MODULES_PATH/$module_path" | |
done | |
cd $SRC_DIR | |
if ! test -d nginx-$NGX_INSTALL_VERSION; then | |
wget "http://nginx.org/download/nginx-$NGX_INSTALL_VERSION.tar.gz" --no-check-certificate | |
tar -xzvf nginx-$NGX_INSTALL_VERSION.tar.gz | |
fi | |
cd nginx-$NGX_INSTALL_VERSION | |
export LUAJIT_LIB=/usr/local/lib | |
export LUAJIT_INC=$LUA_PATH | |
./configure $NGX_CONFIG_ARGS | |
make -j2 | |
make install | |
unset LUAJIT_LIB | |
unset LUAJIT_INC | |
ln -sf /usr/local/lib/libluajit-5.1.so.2 /usr/lib/ | |
wget 'https://raw.github.com/phcostabh/nginx-init-ubuntu/master/nginx' -O /etc/init.d/nginx | |
chmod +x /etc/init.d/nginx | |
update-rc.d -f nginx defaults | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment