Main Contents

Easy Apache authentication

March 11, 2008

Create a file that contains a valid username and password. This file should be outside of your web folders. The first time you create the file provide a username with the option -c (create). Additional users will be appended if you don’t use -c.

# htpasswd2 /var/www/users -c james

Enter a password when prompted.
Create a file called .htaccess in the directory you want secured.

# vi /var/www/localhost/htdocs/secure/.htaccess

AuthUserFile /var/www/users
AuthName My Secure Website
AuthType Basic
Require valid-user

Filed under: Linux |

Sorry, the comment form is closed at this time.