|
Your
Virtual Server Apache web server supports user authentication.
In other words, it allows you to create password protected
directories on your Virtual Server web site. The "Basic"
user-authentication enables you to restrict access to
users who can provide a valid username/password pair.
Creating Password Protected
Directories To create a password
protected directory (http://www.yourcompany.com/bob/)
for Bob, follow these steps.
- Create a file named
.htaccess in your ~/home/enetrics/www/enetrics.com/bob directory
that contains the following.
AuthUserFile /etc/.htpasswd
AuthGroupFile /dev/null
AuthName "Bob's Restaurant"
AuthType Basic
<Limit GET>
require user Bob
</Limit>
This .htaccess
file will only allow one user, Bob, to access the
directory.
The .htaccess
file must reside in the ~/home/enetrics/www/enetrics.com/bob directory
in order to control access to the ~/home/enetrics/www/enetrics.com/bob
directory. You can either create the .htaccess
file while connected to your Virtual Server (using
a file editor like pico, for example), or you
can create the file on your own computer and upload
it to your Virtual Server.
- Use the htpasswd
command to set a password for the new user. Substitute
your Virtual Server login name for LOGIN_NAME
below.
% htpasswd -c /usr/home/LOGIN_NAME/etc/.htpasswd
Bob
You are free to use
a different name or directory location for the password
file. Just change the /usr/home/LOGIN_NAME/etc/.htpasswd
above to whatever you want.
The -c flag
indicates that you are adding a user to the /etc/.htpasswd
for the first time. When you add more users and
passwords to the same password file, the -c
flag is not necessary.
% htpasswd /usr/home/LOGIN_NAME/etc/.htpasswd
peanuts
% htpasswd /usr/home/LOGIN_NAME/etc/.htpasswd
almonds
% htpasswd /usr/home/LOGIN_NAME/etc/.htpasswd
walnuts
Note: You
should be aware of one subtle difference with the
Virtual Server system. When you set up your .htaccess
files, you specify the AuthUserFile or AuthGroupFile
with respect to your home directory. However, when
you set up your .htpasswd files with the
htpasswd command you need to prepend /usr/home/LOGIN_NAME
to the directory specification.
For more information,
see the Apache
Week Article
|