Skip to content

Instantly share code, notes, and snippets.

@melo
Last active December 11, 2015 15:49
Show Gist options
  • Save melo/4623666 to your computer and use it in GitHub Desktop.
Save melo/4623666 to your computer and use it in GitHub Desktop.
Script to compile nginx 1.3.11 with SPDY enabled: includes all dependencies (PCRE and latest OpenSSL) - see config file at the end
#!/bin/sh
PACKAGE="nginx"
NGINX_VERSION="1.3.11"
NGINX_SPDY_PATCH_VERSION="58_1.3.11"
NGINX_NAME="${PACKAGE}-${NGINX_VERSION}"
NGINX_TARBALL="${NGINX_NAME}.tar.gz"
NGINX_URL=http://nginx.org/download/${NGINX_TARBALL}
NGINX_SPDY_PATCH_NAME="patch.spdy-${NGINX_SPDY_PATCH_VERSION}.txt"
NGINX_SPDY_PATCH_URL="http://nginx.org/patches/spdy/${NGINX_SPDY_PATCH_NAME}"
PCRE_VERSION="8.32"
PCRE_NAME="pcre-${PCRE_VERSION}"
PCRE_TARBALL="${PCRE_NAME}.zip"
PCRE_URL="http://downloads.sourceforge.net/project/pcre/pcre/${PCRE_VERSION}/${PCRE_TARBALL}"
OPENSSL_VERSION="1.0.1c"
OPENSSL_NAME="openssl-${OPENSSL_VERSION}"
OPENSSL_TARBALL="${OPENSSL_NAME}.tar.gz"
OPENSSL_URL="http://www.openssl.org/source/${OPENSSL_TARBALL}"
APPS="${HOME}/apps"
PREFIX="${APPS}/${NGINX_NAME}"
INSTDIR="${APPS}/${PACKAGE}"
WORKSPACE="${HOME}/workspace"
### Prepare
mkdir -p "${APPS}" "${WORKSPACE}"
set -e
### PCRE
(
if [ ! -f "${PCRE_TARBALL}" ] ; then
curl -L -C - -O "${PCRE_URL}"
fi
unzip -o ${PCRE_TARBALL}
)
### OpenSSL
(
if [ ! -f "${OPENSSL_TARBALL}" ] ; then
curl -L -C - -O "${OPENSSL_URL}"
fi
tar zxf "${OPENSSL_TARBALL}"
)
### nginx
(
if [ ! -f "${NGINX_TARBALL}" ] ; then
curl -L -C - -O "${NGINX_URL}"
fi
if [ ! -f "${NGINX_SPDY_PATCH_NAME}" ] ; then
curl -L -C - -O "${NGINX_SPDY_PATCH_URL}"
fi
tar zxf "$NGINX_TARBALL"
cd "$NGINX_NAME"
patch -p1 < "../${NGINX_SPDY_PATCH_NAME}"
USE_FILE_AIO='--with-file-aio'
USE_WITH_DEBUG=''
if [ `uname -r | cut -c-6` == "2.6.9-" ] ; then ## Old CentOS systems, no AIO for you
USE_FILE_AIO=""
elif [ `uname -s` == "Darwin" ] ; then ## Mac OS X - no AIO available for you either
USE_FILE_AIO=""
USE_WITH_DEBUG='--with-debug'
if [ `uname -m` == "x86_64"] ; then
patch -p1 < ../darwin64.patch
fi
fi
./configure \
--prefix="$PREFIX" \
$USE_FILE_AIO \
$USE_WITH_DEBUG \
--with-http_ssl_module \
--with-http_spdy_module \
--with-openssl-opt=no-krb5 \
--with-openssl="../${OPENSSL_NAME}" \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-http_secure_link_module \
--without-mail_pop3_module \
--without-mail_smtp_module \
--without-mail_imap_module \
--error-log-path=/dev/fd/2 \
--http-client-body-temp-path="$WORKSPACE/client_body_temp_path" \
--http-proxy-temp-path="$WORKSPACE/proxy_temp_path" \
--http-fastcgi-temp-path="$WORKSPACE/fastcgi-temp-path" \
--with-md5-asm \
--with-sha1-asm \
--with-pcre="../${PCRE_NAME}" \
--with-pcre-jit
make
make install
rm -f "$INSTDIR"
ln -s "$PREFIX" "$INSTDIR"
)
## Sample configuration
server {
server_name www.example.com;
listen 443 ssl spdy;
ssl_certificate /path/to/www.example.com.crt;
ssl_certificate_key /path/to/www.example.com.key;
## enable header compression, its off by default
spdy_headers_comp 5;
access_log off;
root /path/to/www.example.com/docroot;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment