Skip to content

Instantly share code, notes, and snippets.

@lnthien97
Created March 25, 2024 04:27
Show Gist options
  • Save lnthien97/798e63e9a0d3829a4e25fea9ffad54d7 to your computer and use it in GitHub Desktop.
Save lnthien97/798e63e9a0d3829a4e25fea9ffad54d7 to your computer and use it in GitHub Desktop.
#Ubuntu 22.04
# How to install Nginx using nginx-build tools.
## Install nginx-build.
$ wget https://github.com/cubicdaiya/nginx-build/releases/download/v0.11.6/nginx-build-linux-amd64-0.11.6.tar.gz \
-O /tmp/nginx-build.tar.gz && \
tar -xzf /tmp/nginx-build.tar.gz \
-C /usr/local/bin && \
chmod +x /usr/local/bin/nginx-build
## Install common packages.
$ apt update && apt-get install python-git -y && apt-get install dpkg-dev -y && apt-get install software-properties-common -y && apt-get install init-system-helpers -y && apt-get install curl gnupg2 ca-certificates lsb-release -y
## Prepare nginx modules.
$ mkdir -p /opt/nginx-modules
Nginx upstream check module.
$ git clone https://github.com/yaoweibin/nginx_upstream_check_module /opt/nginx-modules/nginx_upstream_check_module
Nginx module vts.
$ git clone https://github.com/vozlt/nginx-module-vts /opt/nginx-modules/nginx_module_vts
Header more nginx module.
$ git clone https://github.com/openresty/headers-more-nginx-module /opt/nginx-modules/headers-more-nginx-module
## Build the nginx source
$ cd /usr/local/src/
$ nginx-build -d work -v 1.17.9 -pcre -openssl -zlib \
-patch /opt/nginx-modules/nginx_upstream_check_module/check_1.14.0+.patch -patch-opt '-p1' \
--prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --user=nginx --group=nginx \
--with-compat --with-file-aio --with-threads --conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock \
--http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/body \
--http-proxy-temp-path=/var/lib/nginx/proxy --with-http_stub_status_module \
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi --with-debug --with-http_gzip_static_module \
--with-http_v2_module --with-http_ssl_module --with-pcre-jit --with-http_realip_module \
--with-http_stub_status_module --with-http_sub_module \
--add-module=/opt/nginx-modules/nginx_module_vts \
--add-module=/opt/nginx-modules/nginx_upstream_check_module \
--add-module=/opt/nginx-modules/headers-more-nginx-module
Make install the source
$ cd work/nginx/1.17.3/nginx-1.17.3
$ sudo make install
Your Nginx is ready to use now.
# List Nginx modules
$ nginx -V
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment