1. Create the directory you want to password protect (example: nikesh)
2. Create a file /var/www/html/nikesh/.htaccess in that director that looks something like this:
AuthName “Add your login message here.”
require user name-of-user
In this case the “name-of-user” is the login name you wish to use for accessing the web site.
3. In apache configuration file, change the AllowOverride to AuthConfig for the directory that you wan to protect with password.
3. Create the password file /etc/apache/.htpasswd using the program htpasswd:
# htpasswd -c .htpasswd name-of-user
Read Man page: htpasswd