How to protect directory with a password in Apache2?
Random | 27 Oct 2014
Tags: ubuntu-server, web-server, apache, password-protect, security
A usual scenario encountered by every web server is administrator is to password protect specific directory and all it's resources. We need to add some lines in the configuration file where our web server / virtual host is defined. This is how we do it:
Creating the password file: (the system will ask you to enter the password which will be saved in encrypted format)
sudo htpasswd -c [filename] [username]
Apache BASIC HTTP Authentication using the created password file
AuthUserFile [the path to the password file] AuthType Basic AuthName "RESTRICTED ACCESS" Require valid-user