Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nasa114/41c679d8c0d8892a7597da2f98ba335b to your computer and use it in GitHub Desktop.
Save nasa114/41c679d8c0d8892a7597da2f98ba335b to your computer and use it in GitHub Desktop.
RPM build Nginx 1.11.x with ALPN on CentOS 6/7 using static LibreSSL 2.5.1.(Not chack 'nginx_libressl.sh')
# Based on CentOS7 fork of @smartmadsoft: https://gist.github.com/moneytoo/ab3f34e4fddc2110675952f8280f49c5
# "6" for CentOS6 or Amazon Linux, "7" for CentOS7
CENTVER="7"
LIBRESSL="libressl-2.5.1"
NGINX="nginx-1.11.0-1"
mkdir -p /opt/lib
# Untar, but don't compile openssl to /opt/lib
wget http://ftp.openbsd.org/pub/OpenBSD/LibreSSL/$LIBRESSL.tar.gz -O /opt/lib/$LIBRESSL.tar.gz
tar -zxvf /opt/lib/$LIBRESSL.tar.gz -C /opt/lib
# Build source nginx (no auto-updates), statically link to /opt/lib/openssl* (no OS effects)
rpm -ivh http://nginx.org/packages/mainline/centos/$CENTVER/SRPMS/$NGINX.el$CENTVER.ngx.src.rpm
# set ssl_module install
sed -i "s|--with-http_ssl_module|--with-http_ssl_module --with-openssl=/opt/lib/$LIBRESSL|g" /root/rpmbuild/SPECS/nginx.spec
# Compile it
rpmbuild -ba /root/rpmbuild/SPECS/nginx.spec
# Based on CentOS7 fork of @smartmadsoft: https://gist.github.com/moneytoo/ab3f34e4fddc2110675952f8280f49c5
# "6" for CentOS6 or Amazon Linux, "7" for CentOS7
CENTVER="7"
LIBRESSL="libressl-2.5.1"
NGINX_VER="1.11.12"
NGINX="nginx-$NGINX_VER-1"
mkdir -p /opt/lib
# Untar, but don't compile openssl to /opt/lib
wget http://ftp.openbsd.org/pub/OpenBSD/LibreSSL/$LIBRESSL.tar.gz -O /opt/lib/$LIBRESSL.tar.gz
tar -zxvf /opt/lib/$LIBRESSL.tar.gz -C /opt/lib
# Build source nginx (no auto-updates), statically link to /opt/lib/openssl* (no OS effects)
rpm -ivh http://nginx.org/packages/mainline/centos/$CENTVER/SRPMS/$NGINX.el$CENTVER.ngx.src.rpm
#sed -i "s|--with-http_ssl_module|--with-http_ssl_module --with-openssl=/opt/lib/$LIBRESSL |g" /root/rpmbuild/SPECS/nginx.spec
# Rewrite SPEC File of nginx version 1.11.8. back up a SPEC file before performing this script.
rm -rf /root/rpmbuild/SPECS/nginx.spec
cp /root/rpmbuild/SPECS/nginx_origin.spec /root/rpmbuild/SPECS/nginx.spec
# Use default SPEC file(ex:nginx 1.11.8)
sed -i s/1.11.8/$NGINX_VER/g /root/rpmbuild/SPECS/nginx.spec
sed -i "s|--with-http_ssl_module|--with-http_ssl_module --with-openssl=/opt/lib/$LIBRESSL |g" /root/rpmbuild/SPECS/nginx.spec
# Compile it
rpmbuild -ba /root/rpmbuild/SPECS/nginx.spec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment