Wednesday, August 12, 2015

Secure site with Password Protection

Secure Site using password:

Step1:- At first open your apache configuration file and add the line AllowOverride All to it.



<Directory /home/abhimanyu/workspace/test/>

    AllowOverride All

Step2:- Now open your .htaccess file and add the following line of code to it



AuthType Basic
AuthName "Restricted Files"
AuthUserFile /etc/apache2/securepass/.htpasswd
Require valid-user

For details of these lines go here.




Step3:- We need a package of apache as utils to get password utility
and can get it by the following command

sudo apt-get install apache2-utils



Step 4:-Now create securepass dir by running



sudo mkdir /etc/apache2/securepass/
                                              then
sudo htpasswd -c /etc/apache2/securepass/.htpasswd username
and add your password



Step 5:--Now restart your apache server by following command
  sudo service apache2 restart
and check at for your site(domain)  and its got password protected.

No comments:

Post a Comment