Ubuntu Notes and How-Tos

Tuesday, March 14, 2006

Enable basic password protection in user homepage

Use this if you don't have access to the apache2.conf:

$ htpasswd -c ~/htpasswd ako
$ sudo chmod 644 ~/htpasswd
$ vim ~/public_html/private/.htaccess

AuthUserFile /home/*/htpasswd
AuthGroupFile /dev/null
AuthName "Private folder"
AuthType Basic
require valid-user

$ chmod 644 ~/public_html/private/.htaccess


Note: This assumes that /etc/apache2/apache2.conf is configured by the admin like this:

<Directory /home/*/public_html>
AllowOverride FileInfo AuthConfig Limit
Options Indexes SymLinksIfOwnerMatch IncludesNoExec
</Directory>


Reload Apache.


If you have access to the apache2.conf:

$ sudo htpasswd -c /etc/apache2/.htpasswd ako
$ sudo chmod 644 /etc/apache2/.htpasswd
$ sudo vim /etc/apache2/apache2.conf

<Directory /home/*/public_html/private>
AuthUserFile /etc/apache2/.htpasswd
AuthGroupFile /dev/null
AuthName "Private folder"
AuthType Basic
require valid-user
</Directory>

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home