sudo htpasswd -c /etc/apache2/.htpasswd amit
If you want to add multiple credentials, omit the -c
flag:
sudo htpasswd /etc/apache2/.htpasswd another_user
AuthUserFile /etc/apache2/.htpasswd
AuthName "Administrator's Area"
AuthType Basic
<Limit GET POST>
require valid-user
</Limit>
location /protected {
auth_basic "Administrator's Area";
auth_basic_user_file /etc/apache2/.htpasswd;
}