PHP / How to generate htpasswd

Very often when I configure a new site on Nginx I have to look up on how to generate htpasswd files. So here is a quick and easy way to do that.
Generate the hashed password using PHP interactive shell:
$ php -a
Interactive shell
php > echo crypt('pass', base64_encode('pass'));
cGhg/8u3.w9r2


Put it in your htpasswd:
$ echo 'you:cGhg/8u3.w9r2' >> /etc/nginx/htpasswd

No comments:

Post a Comment