Build NGINX from source on Ubuntu/Debian amd64.
- NGINX 1.30.7
- OpenSSL 4.1.0
- PCRE2 10.49
bash ngx-depend.sh
bash ngx-build.sh
bash ngx-install.shTo deploy to another VPS instead of installing locally:
bash ngx-repack.sh
# output: /root/nginx-custom-amd64.tar.gzInstalls build dependencies and downloads all sources to /opt/build.
apt packages:
build-essential gcc-14 g++-14 cmake ninja-build pkg-config
automake autoconf libtool git wget curl patch perl
libmaxminddb-dev zlib1g-dev tar xz-utils ca-certificates
sources cloned to /opt/build:
nginx github.com/nginx/nginx
openssl github.com/openssl/openssl
pcre2 github.com/PCRE2Project/pcre2
zlib-ng github.com/zlib-ng/zlib-ng
ngx_brotli github.com/google/ngx_brotli
headers-more-nginx-module github.com/openresty/headers-more-nginx-module
ngx_http_geoip2_module github.com/leev/ngx_http_geoip2_module
ja4andvtsare not downloaded here. Put them in/opt/build/ja4and/opt/build/vtsmanually before runningngx-build.sh.
Compiles NGINX using GCC 14. Output binary: /opt/build/nginx/objs/nginx.
Static modules:
http_ssl, http_v2, http_v3, http_realip, http_stub_status, http_auth_request, http_gunzip, http_gzip_static, http_slice, http_sub, stream, stream_ssl, stream_ssl_preread, stream_realip, ja4, vts
Dynamic modules (.so):
ngx_brotli, headers-more, ngx_http_geoip2
Installs to the system and starts nginx as a systemd service.
Install paths:
/usr/sbin/nginx binary
/usr/lib/nginx/modules/ dynamic modules
/etc/nginx/nginx.conf main config
/etc/nginx/sites-available/ site configs
/etc/nginx/sites-enabled/ active sites
/etc/nginx/ssl/dhparams.pem DH parameters (2048-bit)
/opt/certs/default/ self-signed SSL cert (10yr)
/var/log/nginx/ logs
/var/cache/nginx/ temp files
/var/www/html/ default web root
Existing config files are not overwritten.
Packages the binary and modules into /root/nginx-custom-amd64.tar.gz.
Send to another VPS and install:
scp /root/nginx-custom-amd64.tar.gz root@TARGET_IP:/root/
# on target VPS
mkdir -p /opt/build/nginx/objs /usr/lib/nginx/modules
tar -xzf /root/nginx-custom-amd64.tar.gz -C /tmp/nginx-bundle
cp /tmp/nginx-bundle/bin/nginx /opt/build/nginx/objs/nginx
cp /tmp/nginx-bundle/modules/*.so /usr/lib/nginx/modules/ 2>/dev/null || true
bash ngx-install.shTarget VPS must be Linux amd64 with compatible libc (Ubuntu/Debian). No compiler needed.