Intuitive flags information of Nginx
Nginx is a popular web server and the number of questions asked in ServerFault, the Nginx mailing list and elsewhere is going fast. Whenever you post your question, please remember to include the information on what flags are available or installed in Nginx. This information is available by typing...
nginx -V
The output of the above command may look like the following...
nginx version: nginx/1.2.4
built by gcc 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx-1.2.4 --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/logs/nginx/error.log --http-log-path=/var/logs/nginx/access.log --pid-path=/private/var/run/nginx.pid --lock-path=/private/var/lock/nginx.lock --with-http_ssl_module --with-http_stub_status_module --with-pcre=../pcre-8.31/
It isn't intuitive at the moment. Is it?
To make it readable with ease, please always format it. There are many ways to do so. Here's how I do...
nginx -V 2>&1 | sed 's/--/\'$'\n &/g'
Here's the output of the above command...
nginx version: nginx/1.2.4
built by gcc 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
TLS SNI support enabled
configure arguments:
--prefix=/usr/local/nginx-1.2.4
--sbin-path=/usr/sbin/nginx
--conf-path=/etc/nginx/nginx.conf
--error-log-path=/var/logs/nginx/error.log
--http-log-path=/var/logs/nginx/access.log
--pid-path=/private/var/run/nginx.pid
--lock-path=/private/var/lock/nginx.lock
--with-http_ssl_module
--with-http_stub_status_module
--with-pcre=../pcre-8.31/
There are other advantages on doing so. For example, if you have over 100 flags and you'd want to search if ssl module is installed, you could do the following...
nginx -V 2>&1 | sed 's/--/\'$'\n &/g' | grep ssl
If you wonder why nginx -V | grep ssl
won't help, try that yourself!
Disclaimer: This tip has been tested in Mac OS X (Mavericks), Ubuntu Linux 12.04.x and in Debian Linux 7.x, on a bash shell and in a zsh shell. If it doesn't work in your platform of choice, please comment below and I'm glad to tweak it to work with other platforms too, if possible.
Update: As of May 2021, there is an alternate and much easier way to do the same...
nginx -V 2>&1 | awk 'BEGIN{ RS=" --"; ORS="\n--" } {print $0}'
~ Happy Coding!