apt-get install apache2-utils htpasswd -c /etc/apache2/.htpasswd <username>
AuthType Basic AuthName "Restricted Content" AuthUserFile /etc/apache2/.htpasswd Require valid-user
<Directory /var/www/example> AllowOverride All Options FollowSymlinks AuthType Basic AuthName "Restricted Content" AuthUserFile /etc/apache2/.htpasswd Require valid-user </Directory>
<Location /admin> AuthUserFile /var/www/htpasswd/.htpasswd AuthName "Password Protected Area" AuthType Basic Require valid-user </Location>
Do it for both non-ssl and ssl vhost configuration
apachectl -t systemctl reload apache2