Create a .htaccess file in the directory you want to protect, it should contain at least the following lines
# Access file
order allow,deny
allow from all
require valid-user
Authname "My Protected Page"
Authtype Basic
AuthUserFile /home/sites/sitename/.htpasswd
Now we want to create the htpasswd file using the htpasswd command in the /usr/sbin/ directory. type:
/usr/sbin/htpasswd -c /home/sites/sitename/.htpasswd username
It will prompt you for the password twice
Next chown the two files to a site-admin username or admin. chmod the files to 755
NOTE:
The -c flag in this command signifies that it must create the file. To
add further users to the htpasswd file, repeat the same command WITHOUT
the -c flag.
To use the server's /etc/passwd file then the last line of the .htaccess should be:
AuthUserFile /etc/passwd
Please remember that the above example is generic, it will need to be changed to suit your specific needs. Please refer to the extensive documentation available at Apache's web site for information to assist you in creating the file to suit your needs.