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
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
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>
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
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
1
2
3
4
5
6
7
8
9
10
11
|
<Directory /var/www/website>
AllowOverride AuthConfig
Order Deny,Allow
Allow from all
DirectoryIndex index.php index.html
AuthType Digest
AuthName "RestrictedZone"
AuthDigestProvider file
AuthUserFile /etc/httpd/conf.d/.htdigestpasswd
Require valid-user
</Directory>
|
Now set the username and password with htdigest command.
1
|
htdigest -c /etc/httpd/conf.d/.htdigestpasswd RestrictedZone username
|
now restart the apache service.
1
2
3
|
In Red Hat or CentOS
/etc/init.d/httpd restart
|
1
2
3
|
In Debian or Ubuntu
a2enmod auth_digest
/etc/init.d/apache2 restart
|
Note: In Red Hat and CentOS , when we do
If it is not there then you have to install the mod_auth_digest module.
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.
No comments:
Post a Comment