There are several expmples, but you can do this with either a database backend or via the webserver. The webserver seems to be the quckest to setup... assuming you are running APACHE on LINUX/UNIX you can setup two files the .htaccess and the .htpasswd
Just do a search on GOOGLE for ".htaccess authentication" there are many examples.
Just my .02
PHPdev