Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm disabling access to some folders to unauthorized users this way:

AuthUserFile /var/www/passwords/.htpasswd_private
AuthType Basic
AuthName "Access to private admin section"
Require valid-user

It works fine on the production (Ubuntu) server. The problem is I want the same code to allow access (or at least ask for password) on a windows dev computer.

Tried adding

Allow from

But the logs show error because it cannot find the password file on the dev computer. The system cannot find the path specified. : Could not open password file: C:/var/www/passwords/.htpasswd_private

Whats the elegant way to tell apache to either allow access or ask for password on the dev computer?

share|improve this question
up vote 3 down vote accepted

Create the directory C:/var/www/passwords/.htpasswd_private and then use the htpasswd.exe program that comes with your apache installation to create the .htpasswd_private file

htpasswd -c C:/var/www/passwords/.htpasswd_private username
Automatically using MD5 Format
New password: *********
Re-type password: *********
Adding password for user username

Now you should have a system works like your production server.

share|improve this answer
btw, copying the password files from the production server also works. This is not the elegant solution I wanted (wanted to avoid creating this c:/var folder) but it works. – Niro Jan 24 '12 at 9:21
I know you can copy the file from the production system but I don't know your companies security policy regarding that so I went back to basics. To me as a sysadmin this is elegant as it makes your development system just like (or very similar to) your production system and reduces the work required to put your changes into production. – Iain Jan 24 '12 at 9:32

Allow from does not mean you can just login without password, it just sets what hosts can access it. It will still ask you for a password.

You have two options :

  1. Create a valid .htpasswd_private file in C:/var/www/passwords/.htpasswd_private
  2. You delete these options in your directory declaration :

    AuthUserFile /var/www/passwords/.htpasswd_private

    AuthType Basic

    AuthName "Access to private admin section"

    Require valid-user

And you just leave the Allow from statement.

share|improve this answer

I had a dual htpasswd+LDAP authentication AuthBasicProvider file ldap as follow: AuthType Basic AuthName "MyApp"

AuthBasicProvider file ldap

AuthUserFile /var/www/domain.tld/myapp/.htpasswd

AuthzLDAPAuthoritative off
AuthLDAPURL "ldaps://ldap.domain.tld:636/dc=domain,dc=tld?uid?sub?(&(objectClass=person)(mail=*@domain.tld))" SSL
AuthLDAPBindDN "CN=myapp,OU=Applications,DC=domain,DC=tld"
AuthLDAPBindPassword "xxxxxxxxxx"
AuthLDAPGroupAttribute memberUid
AuthLDAPGroupAttributeIsDN off

Require valid-user

Removing/commenting only the following directives seems to be enough:

  • AuthUserFile
  • AuthzLDAPAuthoritative
  • Require
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.