Apache: Password Protecting Directories
I always forget how to add simple password protection with Apache 2 so here's a reminder to myself.
1. Add directive: "AllowOverride All" (no quotes) into the protected <Directory> configuration entry. Depending on your setup, the <Directory> entry may be under /etc/apache2/apache2.conf or /etc/apache2/sites-available.default. For example:
<Directory />
Options FollowSymLinks
AllowOverride All
SetOutputFilter Deflate
</Directory>
2. Open a shell prompt and cd into the protected directory
3. Run: htpasswd -c .htpassword yourname
Enter your password when requested.
4. Also in the protected directory, create .htaccess file with the following content:
AuthName "restricted area"
AuthUserFile /{full path from the root of the drive}/.htpassword
require valid-user
5. Restart apache with: sudo /etc/init.d/apache2 restart
That should be it.

There are no comments for this entry.
[Add Comment]