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.
http://httpd.apache.org/docs/2.2/programs/htdigest.html
http://httpd.apache.org/docs/2.2/programs/htpasswd.html

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.

About sharad chhetri

Sharad Chhetri is a experienced Linux System Engineer. He loves Linux,Open Source Technology,Wordpress and comedy movies. If you like any of our posts or blog, sincerely recommend you to donate to any charity/open source organisation/needful . We love to hear about your donation at [email protected] . We have already received donations feedback from awesome people. Will you be the next !!

Leave a Reply