I'd like to suggest two easy ways to generate an htpasswd file without having Apache tools installed.
Perl
perl -le 'print crypt("password", "salt")'
So, in bash, we could make something like this:
perl -le 'print crypt("password", "salt")' > /etc/nginx/htpasswd
Ruby (run in irb)
"password".crypt("salt")
If the suggestion is accepted, then the topic in the FAQ page <http://wiki.nginx.org/NginxFaq#How_do_I_generate_an_htpasswd_file_without_having_Apache_tools_installed.3F> could be updated.
Grabbed from: http://snippets.aktagon.com/snippets/109-Password-protecting-a-folder-resource-with-Nginx
Thank you,
Rogério Madureira