Apache authentification

# vi /etc/apache2/sites-enabled/000-default.conf 
<VirtualHost *:80>
    ...
    <Directory "/var/www/html">
      AllowOverride AuthConfig
      Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
      Order allow,deny
      Allow from all
    </Directory>
    ...
</VirtualHost>
 
cat <<EOF> /var/www/html/.htaccess
AuthBasicAuthoritative On
AuthName "Authorized Users Only."
AuthType Basic
AuthUserFile /etc/apache2/htpasswd
Require user USER_NAME
EOF
 
htpasswd -b /etc/apache2/htpasswd USER_NAME 'USER_PASS'