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/example.com/.htpasswd
Require valid-user

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

Comments

Required for comment verification