Password Protect Apache Websites

# vi httpd.conf

Following lines must be there:

<Directory /home/*/public_html>

Allow Override Options Limit AuthConfig

</Directory>

To set a user Jerry with password jer to use the site do:

# vi .htaccess

Add following lines to .htaccess after Options directive and before the Order directive:

AuthType Basic

AuthName “jerry”

AuthDBUserFile /home/dummy/auth

AuthDBGroupFile /home/dummy/auth

require user jerry

require group jerrygroup

:wq

Create file auth in /home/dummy:

# dbmmanage /home/dummy/auth adduser jerry

Enter password for jerry

Add users to group in auth for jerrygroup realm as follows:

# dbmmanage /home/dummy/auth adduser sam passwordsam jerrygroup

# dbmmanage /home/dummy/auth adduser tom passwordtom jerrygroup

i.e.

dbmmanage </home/dummy/auth> adduser userid password group

To delete user:

# dbmmanage /home/dummy/auth delete username

To view users:

# dbmmanage /home/dummy/auth view

auth file is normally available in the /etc/httpd path