openresty 

Send to Kindle
home » snippets » nginx » openresty



Snippets

Build and install openresty

./configure --prefix=/usr/local \
            --with-http_spdy_module \
            --with-http_ssl_module \
            --with-http_stub_status_module \
            --with-md5-asm \
            --with-sha1-asm \
            --with-pcre-jit \
            --with-luajit \
            --with-ipv6 \
            --with-google_perftools_module \
            --with-http_image_filter_module \
            --with-http_geoip_module \
            --with-http_sub_module \
            --with-http_flv_module \
            --with-http_secure_link_module \
            --add-module=ngx-fancyindex

make

sudo make install

Build and install openresty (latest from git) with additional modules

Includes fancyindex

cd /tmp
git clone [email protected]:agentzh/ngx_openresty.git
cd ngx_openresty
make

# Use the right name here
mv ngx_openresty-1.5.11.1rc3 /tmp
cd /tmp/ngx_openresty-1.5.11.1rc3

# Fetch ngx-fancyindex
git clone https://github.com/aperezdc/ngx-fancyindex.git ngx-fancyindex

./configure --prefix=/opt/local/encap \
            --with-http_spdy_module \
            --with-http_ssl_module \
            --with-http_stub_status_module \
            --with-md5-asm \
            --with-sha1-asm \
            --with-pcre-jit \
            --with-luajit \
            --with-ipv6 \
            --with-http_secure_link_module \
            --add-module=ngx-fancyindex

make

sudo make install

On my linux box

./configure --prefix=/opt/local/encap --with-http_ssl_module --with-http_stub_status_module --with-md5-asm --with-sha1-asm --with-pcre-jit --with-luajit --with-ipv6 --with-http_secure_link_module --add-module=ngx-fancyindex

On an Ubuntu like system

export PREFIX=/usr/local
export PREFIX=/usr/local/openresty

upgrade_openresty() {
    set -vxe
    cd /tmp

    # for ldconfig required by nginx's configure script to use luajit
    path=(/sbin $path)

    # Ref https://github.com/openresty/ngx_openresty/releases for releases
    curl -LO https://github.com/openresty/ngx_openresty/archive/v1.7.2.1.tar.gz
    tar zxf v1.7.2.1.tar.gz
    cd ngx_openresty-1.7.2.1

    # this downloads the rest of the stuff and also brings in the configure script
    make

    # make created this sub-directory (same name as our parent.)
    cd ngx_openresty-1.7.2.1

    # get the fancy index module.
    # git clone https://github.com/aperezdc/ngx-fancyindex.git ngx-fancyindex
    curl -LO https://github.com/aperezdc/ngx-fancyindex/archive/v0.3.4.tar.gz

    # get the latest perftools
    sudo aptitude install -y libgoogle-perftools-dev

    # PageSpeed module stuff
    PAGE_SPEED_VERSION=1.8.31.4
    wget https://github.com/pagespeed/ngx_pagespeed/archive/v${PAGE_SPEED_VERSION}-beta.zip
    unzip v${PAGE_SPEED_VERSION}-beta.zip
    (
      cd ngx_pagespeed-${PAGE_SPEED_VERSION}-beta
      curl -O https://dl.google.com/dl/page-speed/psol/${PAGE_SPEED_VERSION}.tar.gz
      tar zxf ${PAGE_SPEED_VERSION}.tar.gz
    )

    # Latest openssl
    # Download from: https://www.openssl.org/source/
    (
      curl -O https://www.openssl.org/source/openssl-1.0.1i.tar.gz
      tar zxf openssl-1.0.1i.tar.gz
      mv openssl-1.0.1i openssl
    )

    ./configure \
        --prefix=$PREFIX \
        --with-http_spdy_module \
        --with-http_ssl_module \
        --with-http_stub_status_module \
        --with-md5-asm \
        --with-sha1-asm \
        --with-pcre-jit \
        --with-luajit \
        --with-ipv6 \
        --with-http_secure_link_module \
        --add-module=ngx-fancyindex-0.3.4 \
        --add-module=ngx_pagespeed-${PAGE_SPEED_VERSION}-beta \
        --with-openssl=$PWD/openssl \
        # configure openresty

    make

    # backup current version

    sudo rsync -rl $PREFIX/nginx{,.bak}/

    # Install this version.
    sudo make install

    # FYI: spits version and configure flags
    $PREFIX/nginx/sbin/nginx -V

    # Confirm openssl is statically linked.
    # The following should not show any output.
    ldd $PREFIX/nginx/sbin/nginx | grep ssl

    # Report the system version of openssl if you didn't statically link it.
    dpkg -l | grep "openssl"
}

misc

C_INCLUDE_PATH=/usr/include/$(gcc -print-multiarch)