Auth: Protect A Site With Password

Add this in the Apache configuration file:

<Directory document_root_for_the_site >
AuthType Basic
AuthName “Restricted access area”
AuthUserFile path_to_passwords_file
Require user username1 username2
</Directory>

The Require user parameter could have a list of usernames space-separated.

Usually path_to_passwords_file is /etc/httpd/passwords
If you can’t find the file:

http://httpd.apache.org/docs/1.3/howto/auth.html

Launch this command:

htpasswd path_to_passwords_file username

Restart the server

This entry was posted in Apache, Security. Bookmark the permalink.

Leave a Reply