Created
June 26, 2018 07:36
-
-
Save mcspring/5c080018217bb024ca8338ed3f747610 to your computer and use it in GitHub Desktop.
Static build of nginx with custom openssl, pcre and zlib
This file contains 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
# Author: Eric Pruitt (http://www.codevat.com) | |
# License: 2-Clause BSD (http://opensource.org/licenses/BSD-2-Clause) | |
# Description: This Makefile is designed to create a statically linked nginx | |
# binary without any dependencies on the host system's version of glibc. | |
NGINX_VERSION=1.15.0 | |
OPENSSL_VERSION=1.0.2o | |
PCRE_VERSION=8.42 | |
ZLIB_VERSION=1.2.11 | |
# URL of nginx source tarball | |
NGINX_SOURCE=https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz | |
# URL of OpenSSL source tarball | |
OPENSSL_SOURCE=https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz | |
# URL of PCRE source tarball | |
PCRE_SOURCE=https://ftp.pcre.org/pub/pcre/pcre-${PCRE_VERSION}.tar.gz | |
# URL of zlib source tarball | |
ZLIB_SOURCE=https://zlib.net/fossils/zlib-${ZLIB_VERSION}.tar.gz | |
all: nginx/nginx | |
amroot: | |
@if [ "$$(id -u)" -ne 0 ]; then \ | |
echo "Must be root to install dependencies."; \ | |
exit 1; \ | |
fi | |
ifeq (/etc/debian_version, $(wildcard /etc/debian_version)) | |
deps: amroot | |
apt-get install libxslt1-dev libxml2-dev zlib1g-dev libbz2-dev | |
else ifeq (/etc/redhat-release, $(wildcard /etc/redhat-release)) | |
deps: amroot | |
yum -y install gcc gcc-c++ make zlib-devel | |
else | |
deps: | |
echo "Linux distribution not supported; install dependencies manually." | |
exit 1 | |
endif | |
clean: | |
rm -rf nginx* openssl* pcre* zlib* | |
nginx.tar.gz: | |
wget -O $@ $(NGINX_SOURCE) | |
nginx: nginx.tar.gz | |
tar xf $< | |
mv nginx-*/ $@ | |
touch $@ | |
pcre.tar.gz: | |
wget -O $@ $(PCRE_SOURCE) | |
pcre: pcre.tar.gz | |
tar xf $< | |
mv pcre*/ $@ | |
touch $@ | |
openssl.tar.gz: | |
wget -O $@ $(OPENSSL_SOURCE) | |
openssl: openssl.tar.gz | |
tar xf $< | |
mv openssl*/ $@ | |
touch $@ | |
zlib.tar.gz: | |
wget -O $@ $(ZLIB_SOURCE) | |
zlib: zlib.tar.gz | |
tar xf $< | |
mv zlib*/ $@ | |
touch $@ | |
build: | |
mkdir -p $@/nginx-${NGINX_VERSION} $@/nginx-${NGINX_VERSION}/sbin $@/nginx-${NGINX_VERSION}/run | |
nginx/nginx: build nginx openssl pcre zlib | |
cd nginx && ./configure --prefix=../build/nginx-${NGINX_VERSION} --sbin-path=./sbin --conf-path=./nginx.conf --pid-path=./run/nginx.pid \ | |
--with-cc-opt="-O2 -static -static-libgcc" --with-ld-opt=-static --with-cpu-opt=generic \ | |
--with-openssl=../openssl \ | |
--with-openssl-opt=no-krb5 \ | |
--with-pcre=../pcre \ | |
--with-zlib=../zlib \ | |
--with-file-aio \ | |
--with-poll_module \ | |
--with-select_module \ | |
--with-http_addition_module \ | |
--with-http_dav_module \ | |
--with-http_flv_module \ | |
--with-http_gunzip_module \ | |
--with-http_gzip_static_module \ | |
--with-http_mp4_module \ | |
--with-http_realip_module \ | |
--with-http_ssl_module \ | |
--with-http_stub_status_module \ | |
--with-http_sub_module \ | |
--with-http_v2_module \ | |
--without-http_access_module \ | |
--without-http_auth_basic_module \ | |
--without-http_autoindex_module \ | |
--without-http_browser_module \ | |
--without-http_charset_module \ | |
--without-http_empty_gif_module \ | |
--without-http_geo_module \ | |
--without-http_memcached_module \ | |
--without-http_map_module \ | |
--without-http_ssi_module \ | |
--without-http_split_clients_module \ | |
--without-http_fastcgi_module \ | |
--without-http_uwsgi_module \ | |
--without-http_userid_module \ | |
--without-http_scgi_module \ | |
--without-mail_pop3_module \ | |
--without-mail_imap_module \ | |
--without-mail_smtp_module | |
cd nginx && $(MAKE) | |
cd nginx && $(MAKE) install | |
.PHONY: all clean cleaner amroot deps |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment