The first thing you will need to do is create a file called .htpasswd (it doesn’t have to be named that way). The following command creates a new .htpasswd file and stores a record in it for user tom.
htpasswd -bc /var/www/yourdomain.com/.htpasswd tom password
To create another user:
htpasswd -b /var/www/yourdomain.com/.htpasswd john password