Home / Get the arguments used to configure Nginx source

Get the arguments used to configure Nginx source

I’m currently managing an images server for a customer that uses Nginx on an old Debian 5 install. At some point they installed a version of Nginx from source, and I wanted to be able to install an updated version from source using the same command line arguments for the configure command. This post shows how to do this.

Show the version and configure options

The nice thing with Nginx is the arguments for the configure command are compiled into the binary and accessible from the command line, so you can ensure your new install is configured in exactly the same way. Simply use the -V flag like so (note it’s an UPPERCASE V):

nginx -V

Here’s some example output from the above command:

nginx version: nginx/1.2.2
built by gcc 4.3.2 (Debian 4.3.2-1.1)
TLS SNI support enabled
configure arguments: --sbin-path=/usr/sbin --pid-path=/var/run/nginx.pid --conf-path=/etc/nginx/nginx.conf --with-http_ssl_module --without-http_rewrite_module

You can then run configure using the “configure arguments” from the output. Using the above example, do this:

./configure --sbin-path=/usr/sbin --pid-path=/var/run/nginx.pid --conf-path=/etc/nginx/nginx.conf --with-http_ssl_module --without-http_rewrite_module

Some other useful command line switches/flags/arguments

See which version is running (without all the other stuff):

nginx -v

Test the current config:

nginx -t