How can I check what modules have been added to an nginx installation?
4 Answers
nginx -V will list all the configured modules. There is no explicit enable/load command.
- 9Note for noobs: If not logged in as root user, the command would be
sudo nginx -Vits_me– its_me2013-02-08 04:08:38 +00:00Commented Feb 8, 2013 at 4:08 - 6I did not need to use
sudoon Ubuntu 14.04Asfand Qazi– Asfand Qazi2015-06-11 14:53:53 +00:00Commented Jun 11, 2015 at 14:53 - 7Please note that this parameter is case sensitive. If you use lower case "-v" you will get only version number. Upper case "-V" gives you complete configuration including list of all modules used for compiling Nginx binary.Illidan– Illidan2016-11-06 07:43:16 +00:00Commented Nov 6, 2016 at 7:43
- 3
- @its_me ...you probably don't need sudo to run
nginx -VCarson Reinke– Carson Reinke2019-07-10 01:30:38 +00:00Commented Jul 10, 2019 at 1:30
Diff-able one-liner:
2>&1 nginx -V | tr -- - '\n' | grep _module Convenient for comparing two environments:
lsmodn="2>&1 nginx -V | tr -- - '\n' | grep _module" diff -y <(ssh www-prd eval $lsmodn) <(ssh www-qa eval $lsmodn) EDIT:
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 ' ' '\n' 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 = '\n'" 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 = '\n' 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 = '\n') <(ssh macosx eval $lsmodn | sort | tr = '\n') Messier, but it works.
- 2
2>&1 nginx -V | tr -- - '\n' | grep _modulecommand is totally wrong as it lists without-* options as installed!Roman Newaza– Roman Newaza2013-03-28 09:07:14 +00:00Commented Mar 28, 2013 at 9:07 - awesome answer. out of interest why do you put 2>&1 in front. from what I've seen thats more unusual?cavalcade– cavalcade2015-02-18 02:46:15 +00:00Commented Feb 18, 2015 at 2:46
- @MattTagg it's only in front until it's used. Then it's at the end of either command.kmarsh– kmarsh2016-06-29 18:23:56 +00:00Commented Jun 29, 2016 at 18:23
nginx -V doesn't show all modules, it shows about 20 modules for me.
I use strings /usr/sbin/nginx|grep _module|grep -v configure| sort which lists all 200+ modules in my nginx.
I also tried objdump but looks like the nginx in my installation had the binary stripped.
- 1This really helps me, and is the only one right answer.
nginx -Vcan't get the build in modules.Willis– Willis2020-06-10 13:05:57 +00:00Commented Jun 10, 2020 at 13:05 - For some reason even this still miss some modules, like
ngx_stream_core_module. Neither doesnginx -Vshow--with-stream. It does work when I add thestreamdirective to the configuration, so it is highly likely for my NGINX to support streaming. I’m using Debian, by the way.Franklin Yu– Franklin Yu2024-07-27 03:17:42 +00:00Commented Jul 27, 2024 at 3:17 - cool solution: you don't even need sudo rights (which is reasonable as it's pretty harmless stuff)folen gateis– folen gateis2024-12-16 17:47:50 +00:00Commented Dec 16, 2024 at 17:47
The
nginx -Vcommand (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/nginx.pid --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
sudofor this command, as superuser powers would only be needed by nginx for opening ports belowIPPORT_RESERVED(e.g., ports below 1024) and/or certain log-files for writing.However, depending on your
$PATHsettings, you may either need to specify the full path — e.g.,/usr/sbin/nginx -V, or indeed usesudofor 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 — http://nginx.org/r/load_module — with the help of theload_moduledirective.