password protect website with .htaccess and .htpasswd - error - "Could not open password file:"

Nicoale picture Nicoale · Apr 6, 2016 · Viewed 14.9k times · Source

We have Plesk site builder through our webhosting with Charter. Using it to create a simple development website.

I am trying to password protect the site using .htaccess / .htpasswd.

I keep getting this error no matter what I do:

[Wed Apr 06 09:02:57 2016] [error] [client 66.169.84.65] (2)No such file or directory: Could not open password file: /.htpasswd
[Wed Apr 06 09:02:57 2016] [error] [client 66.169.84.65] access to / failed, reason: verification of user id 'heather' not configured
[Wed Apr 06 09:03:52 2016] [error] [client 66.169.84.65] (2)No such file or directory: Could not open password file: /etc/httpd/.htpasswd
[Wed Apr 06 09:03:52 2016] [error] [client 66.169.84.65] access to / failed, reason: verification of user id 'admin' not configured
[Wed Apr 06 09:03:56 2016] [error] [client 66.169.84.65] (2)No such file or directory: Could not open password file: /etc/httpd/.htpasswd
[Wed Apr 06 09:03:56 2016] [error] [client 66.169.84.65] access to / failed, reason: verification of user id 'heather' not configured
[Wed Apr 06 09:05:11 2016] [error] [client 66.169.84.65] (2)No such file or directory: Could not open password file: /etc/httpd/HTTP/.htpasswd
[Wed Apr 06 09:05:11 2016] [error] [client 66.169.84.65] access to / failed, reason: verification of user id 'admin' not configured
[Wed Apr 06 09:05:15 2016] [error] [client 66.169.84.65] (2)No such file or directory: Could not open password file: /etc/httpd/HTTP/.htpasswd
[Wed Apr 06 09:05:15 2016] [error] [client 66.169.84.65] access to / failed, reason: verification of user id 'heather' not configured

I'm not very familiar with Parallels Plesk - and getting a hold of their support is like pulling teeth.

  • I've checked and double checked the path to the .htpasswd file; seems right.
  • I've moved it and the .htaccess file to see if I just don't have it in the right place

I'm not sure what the problem is. I get the authentication box (I notice it doesn't have my "Please Login" message though...

enter image description here

here is the code for the .htaccess file:

#
#           AUTHENTICATION
#
### BASIC PASSWORD PROTECTION
AuthUserFile /etc/httpd/HTTP/.htpasswd
AuthName "Please Login"
AuthType basic

<Limit GET POST>
Require valid-user
</Limit>

ANY Help is greatly appreciated or leads in the right direction. THANKS IN ADVANCE!!

Answer

Oleg Neumyvakin picture Oleg Neumyvakin · Apr 7, 2016

Just generate /etc/httpd/HTTP/.htpasswd file by command:

# htpasswd /etc/httpd/HTTP/.htpasswd UserNameYouWant

it asks you for password and generate password file with user UserNameYouWant