-
-
Save Zewy/a7dea63d72b6c9abaa1d0e3be08ac8ee to your computer and use it in GitHub Desktop.
Compile Nginx with OpenSSL on CentOS 7 to support ALPN (and therefore HTTP/2) and ngx_pagespeed
This file contains hidden or 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 | |
## Software versions (you can edit this if there are newer versions) | |
#NPS_VERSION="1.12.34.2" # 2016-12-15 (Beta) | |
NPS_VERSION="1.11.33.4" # 2016-10-03 (Stable) | |
NGINX_VERSION="1.11.9" # 2017-01-24 (mainline) | |
OPENSSL_VERSION="1.1.0d" # 2017-01-26 (stable) | |
PCRE_VERSION="8.39" # 2016-06-14 (old stable, latest supported by Nginx) | |
ZLIB_VERSION="1.2.11" # 2017-01-15 (stable) | |
## File/directory names | |
PAGESPEED="v${NPS_VERSION}-beta" | |
NGINX="nginx-$NGINX_VERSION" | |
OPENSSL="openssl-$OPENSSL_VERSION" | |
PCRE="pcre-$PCRE_VERSION" | |
ZLIB="zlib-$ZLIB_VERSION" | |
## Install development tools (skip this step if you have already installed them) | |
yum -y groupinstall 'Development Tools' | |
## Go to the local source code directory | |
cd /usr/local/src | |
## Download Nginx | |
wget -q https://nginx.org/download/$NGINX.tar.gz | |
tar -xzf $NGINX.tar.gz | |
rm -f $NGINX.tar.gz | |
## Download PageSpeed | |
wget -q https://github.com/pagespeed/ngx_pagespeed/archive/${PAGESPEED}.zip | |
unzip ${PAGESPEED}.zip | |
rm -f ${PAGESPEED}.zip | |
cd ngx_pagespeed-${NPS_VERSION}-beta/ | |
psol_url=https://dl.google.com/dl/page-speed/psol/${NPS_VERSION}.tar.gz | |
[ -e scripts/format_binary_url.sh ] && psol_url=$(scripts/format_binary_url.sh PSOL_BINARY_URL) | |
wget ${psol_url} | |
tar -xzf $(basename ${psol_url}) # extracts to psol/ | |
cd /usr/local/src | |
## Download OpenSSL | |
wget -q https://www.openssl.org/source/$OPENSSL.tar.gz | |
tar -xzf $OPENSSL.tar.gz | |
rm -f $OPENSSL.tar.gz | |
## Download PCRE (there is no secure link, ??) | |
wget -q ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/$PCRE.tar.gz | |
tar -xzf $PCRE.tar.gz | |
rm -f $PCRE.tar.gz | |
## Download Zlib (idem) | |
wget -q http://zlib.net/$ZLIB.tar.gz | |
tar -xzf $ZLIB.tar.gz | |
rm -f $ZLIB.tar.gz | |
## Configure, compile and install | |
cd $NGINX | |
./configure \ | |
--prefix=/usr/local/nginx \ | |
--sbin-path=/usr/sbin/nginx \ | |
--conf-path=/etc/nginx/nginx.conf \ | |
--pid-path=/var/run/nginx.pid \ | |
--error-log-path=/var/log/nginx/error.log \ | |
--http-log-path=/var/log/nginx/access.log \ | |
--user=nginx \ | |
--group=nginx \ | |
--lock-path=/var/run/nginx.lock \ | |
--modules-path=/usr/lib64/nginx/modules \ | |
--http-client-body-temp-path=/var/cache/nginx/client_temp \ | |
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \ | |
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \ | |
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \ | |
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \ | |
--with-compat \ | |
--with-file-aio \ | |
--with-threads \ | |
--with-http_addition_module \ | |
--with-http_auth_request_module \ | |
--with-http_dav_module \ | |
--with-http_flv_module \ | |
--with-http_gunzip_module \ | |
--with-http_gzip_static_module \ | |
--with-http_mp4_module \ | |
--with-http_random_index_module \ | |
--with-http_realip_module \ | |
--with-http_secure_link_module \ | |
--with-http_slice_module \ | |
--with-http_ssl_module \ | |
--with-http_stub_status_module \ | |
--with-http_sub_module \ | |
--with-http_v2_module \ | |
--with-mail \ | |
--with-mail_ssl_module \ | |
--with-openssl=/usr/local/src/$OPENSSL \ | |
--with-pcre=/usr/local/src/$PCRE \ | |
--with-pcre-jit \ | |
--with-stream \ | |
--with-stream_realip_module \ | |
--with-stream_ssl_module \ | |
--with-stream_ssl_preread_module \ | |
--with-zlib=/usr/local/src/$ZLIB \ | |
--with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' \ | |
--add-module=/usr/local/src/ngx_pagespeed-${NPS_VERSION}-beta | |
make && make install | |
## Cleanup | |
cd .. | |
rm -rf $NGINX $OPENSSL $PCRE $ZLIB ngx_pagespeed-${NPS_VERSION}-beta |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment