97 lines
2.6 KiB
Text
97 lines
2.6 KiB
Text
|
#!/bin/bash
|
||
|
|
||
|
PREFIX="/opt/nginx"
|
||
|
|
||
|
TOP="$(pwd)"
|
||
|
|
||
|
pushd sources/nginx/
|
||
|
echo "cleaning nginx sources"
|
||
|
git clean -dxf
|
||
|
popd
|
||
|
|
||
|
BASE_CONFIGURE_FLAGS=(
|
||
|
# Build everything with Clang + ThinLTO
|
||
|
--with-cc="clang"
|
||
|
--with-cc-opt="-pipe -march=native -mtune=native -flto=thin"
|
||
|
--with-ld-opt="-march=native -mtune=native -flto=thin"
|
||
|
|
||
|
# Use CloudFlare zlib
|
||
|
--with-zlib="$TOP/sources/cf-zlib"
|
||
|
--with-zlib-opt="-O3 -march=native -mtune=native -pipe -flto=thin"
|
||
|
|
||
|
--with-compat
|
||
|
--with-debug
|
||
|
--with-file-aio
|
||
|
--with-http_addition_module
|
||
|
--with-http_auth_request_module
|
||
|
--with-http_dav_module
|
||
|
--with-http_degradation_module
|
||
|
--with-http_flv_module
|
||
|
--with-http_geoip_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
|
||
|
# we don't need this functionality, so
|
||
|
# we strip it from our builds
|
||
|
#
|
||
|
# --with-mail
|
||
|
# --with-mail_ssl_module
|
||
|
|
||
|
--with-pcre-jit
|
||
|
--with-stream
|
||
|
--with-stream_geoip_module
|
||
|
--with-stream_realip_module
|
||
|
--with-stream_ssl_module
|
||
|
--with-stream_ssl_preread_module
|
||
|
--with-threads
|
||
|
|
||
|
# Add modules into the build we use
|
||
|
--add-module=$TOP/sources/modules/nginx-module-vts
|
||
|
--add-module=$TOP/sources/modules/ngx-fancyindex
|
||
|
# --add-module=$TOP/sources/modules/nginx-rtmp-module
|
||
|
# --add-module=$TOP/modules/nginx-dav-ext-module
|
||
|
)
|
||
|
|
||
|
# Do a dummy config of cloudflare zlib so nginx build can actually distclean and do what it wants..
|
||
|
pushd $TOP/sources/cf-zlib
|
||
|
CFLAGS="-O3 -march=native -mtune=native -pipe -flto=thin -pipe" CC="clang" \
|
||
|
./configure
|
||
|
popd
|
||
|
|
||
|
pushd $TOP/sources/nginx
|
||
|
|
||
|
./auto/configure \
|
||
|
--prefix=$PREFIX/etc/nginx \
|
||
|
--conf-path=$PREFIX/etc/nginx/nginx.conf \
|
||
|
--sbin-path=$PREFIX/usr/bin/nginx \
|
||
|
--pid-path=/run/nginx.pid \
|
||
|
--lock-path=/run/lock/nginx.lock \
|
||
|
--user=http \
|
||
|
--group=http \
|
||
|
--http-log-path=/var/log/nginx/access.log \
|
||
|
--error-log-path=stderr \
|
||
|
--http-client-body-temp-path=/var/lib/nginx/client-body \
|
||
|
--http-proxy-temp-path=/var/lib/nginx/proxy \
|
||
|
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
|
||
|
--http-scgi-temp-path=/var/lib/nginx/scgi \
|
||
|
--http-uwsgi-temp-path=/var/lib/nginx/uwsgi \
|
||
|
"${BASE_CONFIGURE_FLAGS[@]}"
|
||
|
|
||
|
make -j $(($(nproc)+1))
|
||
|
#sudo systemctl stop nginx-cn
|
||
|
# strip binary of unneeded fluff (saving the original)
|
||
|
# cp objs/nginx objs/nginx.unstripped
|
||
|
# strip objs/nginx
|
||
|
# sudo cp objs/nginx /opt/nginx/usr/bin
|
||
|
#sudo systemctl start nginx-cn
|
||
|
#sudo make install
|
||
|
popd
|