Snippet: Setting HTTP_AUTH in Apache2

Simple task, but I always forget details, so putting this script for future reference. It helps you protect your website (for example dev version) via basic http authorisation.
1
2
3
4
5
6
7
8
  1. # Put these lines inside <Directory> tag of your virtual host file:
  2. AuthType Basic
  3. AuthName "Private Club Entrance"
  4. AuthUserFile /var/www/example.com/.htpasswd
  5. Require valid-user
  6. # Create a new user via command:
  7. htpasswd -c /var/www/example.com/.htpasswd username