Learn more about the world's best-loved Web server, with examplesof Apache's authentication and logging capabilities, and also pay a briefvisit to its unique URL re-writing module.
If you've been paying attention, you'll have noticed that there's one thingmissing - the authorization file itself. And Apache comes with its ownlittle utility to create the file - it's called "htpasswd".
Switch to the directory specified in the AuthUserFile directive above, adrun the "htpasswd" command to create a file containing authorized users -you might see something like this:
$ htpasswd -c users joe
Adding password for joe.
New password:
Re-type new password:
And if you peek into the file "users", you'll see that the user has beenadded to the file - the garbage next to the user name is the password youjust entered, in encrypted form.
$ cat users
joe:9DyNcHx.8JOp2
You can add as many users as you like using the method above (remember toomit the -c parameter, though, since that's only used when creating a filefor the first time).
With everything in place, start up your browser and point it to thedirectory you just protected. The Web server should immediately pop up adialog box asking for a username and password, and will only allow youto view the contents of the directory if you enter the correct values.Ain't that cool?