Logicalwebhost Cheatsheet

Linux & Open Source Cheatsheets & Howto's

Skip to: Content | Sidebar | Footer


15 January, 2011 (00:10) | commands | By: unclecameron

install .htaccess

apt-get install htpasswd

add user

cd /where/your/secret/.htpasswd/file/will/be/created
htpasswd -c .htpasswd usertocreate
htpasswd .htpasswd anotheruser

create .htaccess file

in the directory you want to control access, create a new file like

vi .htaccess
  AuthUserFile /pathtowhereyouwantthepasswordfile/.htpasswd
  AuthName "Authorization Required"
  AuthType Basic
  require valid-user
chown www-data.www-data .htaccess (use whatever your system uses for apacheuser/group, Ubuntu is www-data.www-data)

tell apache to allow .htaccess use

open your apache directive file for your site and change the AllowOverride line to

AllowOverride AuthConfig

now visit your page, you should get a prompt for a username/password

Write a comment

You need to login to post comments!