• The nginx -V command (upper-case V) will list all the modules, as well as other compile-time options:

    %nginx -V nginx version: nginx/1.2.2 built by gcc 4.2.1 20070719 TLS SNI support enabled configure arguments: --prefix=/var/www --conf-path=/etc/nginx/nginx.conf --sbin-path=/usr/sbin/nginx --pid-path=/var/run/ --lock-path=/var/run/nginx.lock --http-log-path=logs/access.log --error-log-path=logs/error.log --http-client-body-temp-path=/var/www/cache/client_body_temp --http-proxy-temp-path=/var/www/cache/proxy_temp --http-fastcgi-temp-path=/var/www/cache/fastcgi_temp --http-scgi-temp-path=/var/www/cache/scgi_temp --http-uwsgi-temp-path=/var/www/cache/uwsgi_temp --user=www --group=www --with-http_gzip_static_module --with-http_ssl_module --with-http_stub_status_module --with-ipv6 --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module %

    Note that there is never any need for sudo for this command, as superuser powers would only be needed by nginx for opening ports below IPPORT_RESERVED (e.g., ports below 1024) and/or certain log-files for writing.

    However, depending on your $PATH settings, you may either need to specify the full path — e.g., /usr/sbin/nginx -V, or indeed use sudo for having the appropriate /sbin/ directory be included in the $PATH.

  • Starting with newer nginx releases — since nginx 1.9.11 (February 2016) — dynamically loadable modules are now supported, too — — with the help of the load_module directive.

  • 1
Reply Report

Diff-able one-liner:

2>&1 nginx -V | tr -- - '
' | grep _module

Convenient for comparing two environments:

lsmodn="2>&1 nginx -V | tr -- - '
' | grep _module"
diff -y <(ssh www-prd eval $lsmodn) <(ssh www-qa eval $lsmodn)


Thank you, Roman Newaza, for correctly pointing out that this includes --without module compile flags. I'm not using --without flags and was just focused on getting the module list, so I didn't catch that; the one-liner can be modified to help diff compile flags between 2 installations, like this:

2>&1 nginx -V | tr ' '  '

which is the same as:

2>&1 nginx -V | xargs -n1

Maybe also pipe that through sort to normalize idiosyncratic ordering of compile flags and tr again to split assignments onto diff-able lines. Final result:

lsmodn="2>&1 nginx -V | xargs -n1 | sort | tr = '
diff -y <(ssh www-prd eval $lsmodn) <(ssh www-qa eval $lsmodn)

That works if sort behaves the same on both remote hosts (ie. they are both GNU or BSD). If you are comparing Linux to BSD (Mac OS X), just move the | sort | tr = ' ' piece out of lsmodn to the local shell where sort will be consistent:

lsmodn="2>&1 nginx -V | xargs -n1"
diff -y <(ssh linux eval $lsmodn | sort | tr = '
') <(ssh macosx eval $lsmodn  | sort | tr = '

Messier, but it works.

  • 1
Reply Report