Skip to content

Instantly share code, notes, and snippets.

@marklkelly
Last active May 19, 2017 10:30
Show Gist options
  • Save marklkelly/6ea3bac4b5b56d9f5ab1 to your computer and use it in GitHub Desktop.
Save marklkelly/6ea3bac4b5b56d9f5ab1 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -o errexit
clear
# Set versions. Check http://openresty.org for latest version and bundled version of nginx.
OPENRESTY_VERSION=1.9.3.1
NGINX_VERSION=1.9.3
OPENSSL_VERSION=1.0.2d
LUANGINX_VERSION=0.9.16
# Install some pre-requisites
yum install -y readline-devel pcre-devel gcc zlib-devel patch
# Get OpenResty
cd /usr/local/src/
wget http://openresty.org/download/ngx_openresty-${OPENRESTY_VERSION}.tar.gz
tar vxf ngx_openresty-${OPENRESTY_VERSION}.tar.gz
# Get OpenSSL
wget https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz
tar vxf openssl-${OPENSSL_VERSION}.tar.gz
# Get ssl-cert-by-lua branch from github, replace lua-nginx-module and apply patch
wget https://github.com/openresty/lua-nginx-module/archive/ssl-cert-by-lua.tar.gz
tar vxf ssl-cert-by-lua.tar.gz
cd /usr/local/src/ngx_openresty-${OPENRESTY_VERSION}/bundle/ngx_lua-${LUANGINX_VERSION}/
rm -rf *
cp -r /usr/local/src/lua-nginx-module-ssl-cert-by-lua/* .
cd /usr/local/src/ngx_openresty-${OPENRESTY_VERSION}/bundle/nginx-${NGINX_VERSION}/src/event
patch < /usr/local/src/lua-nginx-module-ssl-cert-by-lua/patches/nginx-ssl-cert.patch
# Now we can build OpenResty / Nginx.
cd /usr/local/src/ngx_openresty-${OPENRESTY_VERSION}
./configure --with-http_ssl_module \
--with-luajit \
--with-openssl=/usr/local/src/openssl-${OPENSSL_VERSION}
mkdir -p /usr/local/openresty/lualib/ngx
cp build/ngx_lua-${LUANGINX_VERSION}/lua/ngx/ssl.lua /usr/local/openresty/lualib/ngx/ssl.lua
# Check install.
/usr/local/openresty/nginx/sbin/nginx -t
/usr/local/openresty/nginx/sbin/nginx -V
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment