First make sure that .htaccess overrides are enabled in /etc/apache2/sites-enabled/domain.conf
Then create a .htaccess file in the directory you want to protect:
Options +Indexes AuthType Basic AuthName "Restricted Content" AuthUserFile /etc/apache2/ocna.htpasswd Require valid-user
Now create valid users in the file /etc/apache2/ocna.htpasswd:
htpasswd -c /etc/apache2/ocna.htpasswd username
For subsequent users, just use:
htpasswd /etc/apache2/ocna.htpasswd username
Joel G Mathew, known in tech circles by the pseudonym Droidzone, is an opensource and programming enthusiast.
His favorite pastime is grappling with GNU compilers, discovering newer Linux secrets, writing scripts, hacking roms, and programs (nothing illegal), reading, blogging. and testing out the latest gadgets.
When away from the tech world, Dr Joel G. Mathew is a practising ENT Surgeon, busy with surgeries and clinical practise.