AuthUserFile not working, what could be wrong?

user692601 picture user692601 · Oct 25, 2011 · Viewed 19.3k times · Source

I'm using CentOS and I switched servers last night. I'm having a problem with the AuthUserFile file.

I always get blocked. I made sure that:

  1. The path is the real path:

    AuthUserFile /home/rootvideo/.htpasswd
    
  2. The /home/rootvideo/.htpasswd and .htaccess file has 0644 permissions.

  3. httpd.conf is set to AllowOverride All in all of the folders.

  4. All the mod_auth are loaded.

    LoadModule authn_file_module modules/mod_authn_file.so
    LoadModule authn_alias_module modules/mod_authn_alias.so
    LoadModule authn_anon_module modules/mod_authn_anon.so
    LoadModule authn_dbm_module modules/mod_authn_dbm.so
    LoadModule authn_default_module modules/mod_authn_default.so
    LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
    

Any ideas?

Answer

SvennD picture SvennD · Jan 7, 2015

For future reference :

Chmodd the file to 0660 the parent directory to 0755 and the owner of the file should be the apache user. For debian variants (ubuntu) this is www-data. For CentOS its apache.

chmod 0660 /mylocation/.htpasswd
chmod 0775 /mylocation
# centOS
chown apache:apache /mylocation/.htpasswd
# ubuntu
chown www-data:www-data /mylocation/.htpasswd

Finding what user you need :

grep -e '^User' /etc/apache2/apache2.conf
grep -e '^User' /etc/httpd/conf/httpd.conf