Realms: Areas of Controlled Access

In terms of voluntary control mechanisms on the Web, each protected area, whether it be a single document or an entire server, is called a realm. When a server challenges a client for credentials, it provides the name of the realm so the client can figure out which credentials to send.

The name of a realm is specified in the Apache configuration files with the AuthName directive, which takes a single argument: the name of the realm.
The ScreenCast session explain how to apply it, look to the desktop recording of realm creation .

This directive could be applied to <directory> and <location> inside apache httpd.conf and works also when modules are applied, for example WEBDAV.
The directive must be placed inside httpd.conf and require that you reboot apache with apachectl graceful

In this example we will apply a REALM to the test location:

 <Location /test>
    AllowOverride None
    Options None
      AuthType Basic
      AuthName "Protected Area"
      AuthUserFile /mnt/flash/.htpasswd
      # only authenticated users may access this location
      Require valid-user

 The directive AuthUserFile specify the place where access credential are placed. To generate this file you should use htpasswd command:

htpasswd -c .htpasswd username

The command syntax is -c (create) filename (.htpasswd) and the username to use (MAN PAGES )

See also: