[Web server] Authentication folder on Apache with htpasswd file or LDAP

Step 1. Authentication method:
S1. Authentication by file passwd
- Create password file
sudo nano /var/www/.passwd.txt
- Create new a user:
htpasswd /var/www/.passwd.txt username
- Create virtual host with passwd file for test folder in /etc/apache2/sites-enabled:
<Directory "/var/www/test/">        
AuthUserFile "/var/www/.passwd.txt"
AuthName "Please login for test"
AuthType Basic                
require user admin
</Directory>
S2. Authentication by LDAP
- Enable ldap mod:
a2enmod ldap authnz_ldap
sudo /etc/init.d/apache2 restart
- Create virtual host file in /etc/apache2/sites-enabled:
<Location /abc>
AuthType Basic
AuthName "Please type your username and password"
Order deny,allow
Allow from all
AuthBasicProvider ldap
AuthLDAPURL ldap://192.168.1.101:389/CN=Users,DC=domainname,DC=local?sAMAccountName?sub?(objectClass=user)
AuthLDAPBindDN username@domainname.local
AuthLDAPBindPassword password
AuthzLDAPAuthoritative off
# Authentication for all users of LDAP
require valid-user
# Authentication for multi users of LDAP
require user username1 username2
</Location>
Step 2. Restart apache
sudo /etc/init.d/apache2 restart