DevOpsDevOps

Setting HTTP_AUTH in Apache2

Jun 02, 2015 · Updated: Nov 07, 2017 · by Tim Kamanin

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 authorization.

# Put these lines inside <Directory> tag of your virtual host file:
AuthType Basic
AuthName "Private Club Entrance"
AuthUserFile /var/www/example.com/.htpasswd
Require valid-user

# Create a new user via command:
htpasswd -c /var/www/example.com/.htpasswd username

Hey, if you've found this useful, please share the post to help other folks find it:

There's even more:

Subscribe for updates

  • via Twitter: @timonweb
  • old school RSS:
  • or evergreen email ↓ ↓ ↓