Compile and install Nginx from source with optional modules.
- x86, x64, arm*
- Debian 8 and later
- Ubuntu 16.04 and later
- Latest mainline or stable version, from source
- Optional modules (see below)
- Removed useless modules
- Custom nginx.conf (default does not work)
- Init script for systemd (not provided by default)
- Logrotate conf (not provided by default)
- Block Nginx installation from APT using pinning, to prevent conflicts
- LibreSSL from source (CHACHA20, ALPN for HTTP/2, X25519, P-521)
- OpenSSL from source (TLS 1.3, CHACHA20, ALPN for HTTP/2, X25519, P-521)
- ngx_pagespeed (Google performance module)
- ngx_brotli (Brotli compression algorithm)
- ngx_headers_more (Custom HTTP headers)
- ngx_http_geoip2_module with libmaxminddb and GeoLite2 databases
- ngx_cache_purge (Purge content from FastCGI, proxy, SCGI and uWSGI caches)
- ngx-fancyindex (Fancy indexes module)
- nginx-dav-ext-module (nginx WebDAV PROPFIND,OPTIONS,LOCK,UNLOCK support)
- nginx-module-vts (Nginx virtual host traffic status module)
- See install instructions: nginx-module-vts#installation
- ModSecurity from source (ModSecurity is an open source, cross platform web application firewall (WAF) engine for Apache, IIS and Nginx)
- ModSecurity-nginx (ModSecurity v3 Nginx Connector)
- HTTP/3 using Cloudflare's patch with Quiche and BoringSSL.
- testcookie-nginx-module (testcookie-nginx-module is a simple robot mitigation module using cookie based challenge/response.)
- See example configuration testcookie-nginx-module#example-configuration
- lua-nginx-module (Embed the power of Lua into Nginx HTTP Servers)
- luajit2 (OpenResty's maintained branch of LuaJIT)
- ngx_devel_kit (Nginx Development Kit (NDK))
- Cloudflare's TLS Dynamic Record Resizing patch maintained by nginx-modules.
Just download and execute the script :
wget https://raw.githubusercontent.com/angristan/nginx-autoinstall/master/nginx-autoinstall.sh
chmod +x nginx-autoinstall.sh
./nginx-autoinstall.sh
You can check configuration examples for the custom modules.
Just select the option when running the script :
You have the choice to delete the logs and the conf.
To update Nginx, run the script and install Nginx again. It will overwrite current Nginx files and/or modules.
The update feature downloads the script from this repository, and overwrites the current nginx-autoinstall.sh
file in the working directory. This allows you to get the latest features, bug fixes, and module versions automatically.
This option will install Nginx Bad Bot and User-Agent Blocker. (Nginx Bad Bot and User-Agent Blocker, Spam Referrer Blocker, Anti DDOS, Bad IP Blocker and Wordpress Theme Detector Blocker)
See additional steps to add a cron job for automatic updating, customization and testing in the link above.
You can run the script without the prompts with the option HEADLESS
set to y
.
HEADLESS=y ./nginx-autoinstall.sh
To install Nginx mainline with Brotli:
HEADLESS=y \
NGINX_VER=2 \
BROTLI=y \
./nginx-autoinstall.sh
To uninstall Nginx and remove the logs and configuration files:
HEADLESS=y \
OPTION=2 \
RM_CONF=y \
RM_LOGS=y \
./nginx-autoinstall.sh
All the default variables are set at the beginning of the script.
GPL v3.0