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
Allow from all
DirectoryIndex index.php index.html
Now set the username and password with htdigest command.
htdigest -c /etc/httpd/conf.d/.htdigestpasswd RestrictedZone username
now restart the apache service.
In Red Hat or CentOS
In Debian or Ubuntu
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.
- Install Openssh server on Ubuntu Desktop / Server - November 16, 2014
- Install MariaDB Server 10.0 on Ubuntu 14.04 LTS ( Trusty Tahr ) - November 15, 2014
- Redirect sudo output to file - November 13, 2014
- 3 Steps to install skype 4.3 on Ubuntu 14.04 / 12.04 - November 8, 2014
- Install Owncloud 7 on Ubuntu 14.04 LTS Server - November 6, 2014
- cron job not working : troubleshooting steps - November 5, 2014
- tr command to convert lines to space , tab and vertical tab - October 31, 2014
- Bash : print variable value inside single and double quotes - October 16, 2014
- CentOS 7 / RHEL 7 : change OpenSSH port number ( SELINUX enabled ) - October 15, 2014
- CentOS 7 / RHEL 7 : Reset / Recover forgotten root password - October 11, 2014