Setting HTTP_AUTH in Apache2

02 Jun · by Tim Kamanin · 1 min read

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/
Require valid-user

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

Want to get more 🔥 tips like this one?

Subscribe to get notified about new dev tutorials