Password Protection Setup


For the instructions given, the following names are arbitrary:

passwords    name of the directory in which the password file is located (better to choose a more obscure name)
passfilename of the password file -- typically  .htpasswd
usernamename of the user
passwordpassword for given user
pagename of the directory in which the protected web page is located

create password directory
mkdir passwords
should be "outside" the normal web directory structure

home
wwwpasswords
page 
set permissions
chmod a+rx passwords
 
change to password directory
cd passwords
 
execute htpasswd program
htpasswd -c passfile username
program will prompt for password
typically use .htpasswd for password file name
  to add user to existing list, execute htpasswd without the -c
  to delete user from existing list, edit passfile and delete line
  to change a password, delete the user, then add it back with the new password
set permissions
chmod a+r passfile
 
change to page directory
cd ../www/page
 
create new file with name .htaccess enter the following information:
    AuthUserFile <absolute path to password file>
    AuthName "<descriptive name for site>"
    AuthType Basic

    <LIMIT GET POST>
    require valid-user
    </LIMIT>
set permissions
chmod a+r .htaccess
 
create a link to a web page in the page directory
attempt to access the protected page using a browser
the browser should prompt you for a username and password
after entering the user name and password, the page should load normally
you should be able to access the page (and all pages in any subdirectories) without re-entering the password until you restart the browser

Note .htaccess protects the contents of the directory page and all its subdirectories.