How to set htdigest password in apache web server

How to set htdigest password in apache web server

Through this method we can set the username and password in webserver means whenever anyone open the website he has to give username and password to see the content of website.

To know about what is the difference in htdigest and htpasswd. Kindly visit these links.

The practical has been done in given below apache version but applicable in almost all version of apache
Apache Package Version : httpd-2.2.3-76

you have to do these settings in you apache configuration file.
Here I did this in /etc/httpd/conf/httpd.conf
If you have custom file other than this so you have to edit that configuration file only.
I wrote this settings inside </VirtualHost>

Directory “/var/www/html/website” = This is the location of your webspace directory.
AllowOverride AuthConfig = Allow use of the authorization directives (AuthDBMGroupFile, AuthDBMUserFile, AuthGroupFile, AuthName, AuthType, AuthUserFile, Require, etc.).
AuthType = Here we are using Digest type
AuthName = In htdigest command it is for realm value.
AuthDigestProvider file = The AuthDigestProvider directive sets which provider is used to authenticate the users for this location. The default file provider is implemented by the mod_authn_file module.
AuthUserFile /etc/httpd/conf.d/.htdigestpasswd = Location of file where username passwd is saved
Require valid-user = Only valid user can able to login .The user which you created through htdigest command

Now set the username and password with htdigest command.

now restart the apache service.

Note: In Red Hat and CentOS , when we do yum install httpd at the time of installation mod_auth_digest is also installed like other module bydefault install. You can check by ls -l /etc/httpd/modules |grep digest
If it is not there then you have to install the mod_auth_digest module.