How to list installed Nginx modules and compiled flags

How do I list installed Nginx modules? How can I find which flags the Nginx server compiled with on Linux and Unix-like operating systems?

We can easily see which flags Nginx was compiled with using the nginx command itself. The same command also lists installed Nginx modules. This page explains the various command-line options for developers and sysadmin to determine if the particular feature is compiled.

ADVERTISEMENTS

Linux list installed Nginx modules

Make sure you run nginx command as the root user (sudo nginx -V), and nginx is in your $PATH.

Open the terminal app and then type the following command:
$ nginx -V

nginx version: nginx/1.18.0 (Ubuntu)
built with OpenSSL 1.1.1f  31 Mar 2020
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fdebug-prefix-map=/build/nginx-5J5hor/nginx-1.18.0=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fPIC' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-compat --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_xslt_module=dynamic --with-stream=dynamic --with-stream_ssl_module --with-mail=dynamic --with-mail_ssl_module

Nginx list installed modules in neat format

The -V option passed to the nginx command. It lists all the configured Nginx modules. However, the output is not easy to read or searchable using the egrep command/grep command. For example, see if Nginx compiled with stub_status_module, run:
$ nginx -V | grep --color stub_status_module
More readable syntax:
$ nginx -V 2>&1 | tr ' ' '\n'
$ nginx -V 2>&1 | tr ' ' '\n' | grep 'something'
$ nginx -V 2>&1 | tr ' ' '\n' | grep 'ssl'
$ nginx -V 2>&1 | tr ' ' '\n' | egrep -i 'ssl|brotli|pagespeed'

Linux list installed Nginx modules and compiled flags
Please note that ‘2>&1‘ will redirect stderr and stdout to the tr command command using shell pipes. See “BASH Shell Redirect stderr To stdout ( redirect stderr to a File )” for detailed explanation.

Find which flags Nginx was compiled with under Unix

The same command lists compiled and dynamic modules under Nginx:
$ nginx -V
$ nginx -V 2>&1 | tr ' ' '\n'

--prefix=/usr/share/nginx
--conf-path=/etc/nginx/nginx.conf
--http-log-path=/var/log/nginx/access.log
--error-log-path=/var/log/nginx/error.log
--lock-path=/var/lock/nginx.lock
--pid-path=/run/nginx.pid
--modules-path=/usr/lib/nginx/modules
--http-client-body-temp-path=/var/lib/nginx/body
....
..

Other nginx command options

Display nginx version and exit:
$ nginx -v # small -v
To see version and configure options, run:
$ nginx -V # CAPITAL -V
Test nginx configuration for errors:
$ nginx -t

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: [emerg] mkdir() "/var/lib/nginx/body" failed (2: No such file or directory)
nginx: configuration file /etc/nginx/nginx.conf test failed

Hide non-error messages during configuration testing
$ nginx -t -q
We can test configuration, and dump it on the screen:
$ nginx -T
Send a signal to control the Nginx server:
$ sudo nginx -s signal
Stop the Nginx server:
$ sudo nginx -s stop
Reload the Nginx server after making changes to the config file or when TLS/SSL certificate created/issues/renewed:
$ sudo ngix -s reload
Reopen log files after creating log files stored in /var/log/nginx/:
$ sudo ngix -s reopen

Conclusion

In this quick tutorial, we learned how to see which flags Nginx compiled with, including listing Nginx modules.

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
2 comments… add one
  • HN Jul 18, 2020 @ 4:14

    Why Nginx? Why not Apache?

  • vikas Aug 28, 2020 @ 15:56

    Great article!
    what is the command to show modules added with the --add-module switch?

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.