1

I just installed Apache Web Server on Ubuntu 11.04 in VMWare Workstation. I created a basic HTML page, named it index.html and placed it in /var/www directory (document root).

I am able to access this web page from my Host OS (Windows 7), by pointing the browser to:

http://192.168.2.2/index.html

where, 192.168.2.2 is the IP Address of the Ubuntu VM.

Next, to test various configurations of .htaccess files, I created a new directory in /var/www called, members.

Inside this directory, I created and placed a .htaccess file with the following configuration:

AuthUserFile /www/Neon/auth/.htpasswd
AuthName "neon's home"
AuthType Basic
require valid-user
IndexIgnore */*

I created a directory path like /var/www/Neon/auth/

and then placed a .htpasswd file inside it.

To place the username and hash inside the .htpasswd file: I created a username "neon" and calculated the DES hash of a password and placed it inside .htpasswd file in format:

username:hash

Now, when I try to access the web page: http://192.168.2.2/members/

It does not prompt me to enter the username and password with a popup box. Instead it just displays the index.html which is placed inside members directory.

I would like to get this configuration working :)

4 Answers 4

1

First guess: you are missing the AuthGroupFile which may be set to /dev/null to disable all group functionality.

Other guess: look in the error_log for the specific server/vhost.

2
  • Ok. I will check it. Thanks. There is only one document root in the VM. I have not hosted multiple sites. The HTML pages are placed in the default document root, /var/www. So, I did not understand what you mean by specific server/vhost in my configuration? Can you elaborate over that?
    – Neon Flash
    Oct 3, 2012 at 3:33
  • I'm used to configurations with lots of virtualhosts with an ErrorLog directive per virtual host, so that will take some searching finding the 'right' logfile. In your case, their is only one place to search, the main ErrorLog. Oct 5, 2012 at 11:06
1

I would suggest using Apache's built-in tool for generating the htpasswd entries.

htpasswd -c /www/Neon/auth/.htpasswd username

This will create the .htpasswd file for you. When you go to add a new username to that file, omit the -c option and it will append new entries to it.

0

Check this site: http://www.htaccesstools.com/htpasswd-generator/

It can help you generate a correct .htpasswd file.

Are you sure that in you site conf /etc/apache2/sites-avaliable (if you are using apache) there is the directive "AllowOverride All"? If not, the .htaccess will be ignored from apache.

Sorry for bad english, but I'm italian.

2
  • Hi. I think my .htpasswd file is correct. Do I need to edit, /etc/apache2/apache2.conf file? I tried adding the AllowOverride All directive. However, when I restart apache using, /etc/init.d/apache2 restart, I get the error: "Syntax error on line 176 of /etc/apache2/apache2.conf: AllowOverride not allowed here ". can you give a sample configuration? My .htaccess file is in the, /var/www/members/ location.
    – Neon Flash
    Oct 2, 2012 at 8:48
  • 1
    Ok, I found and edited, the /etc/apache2/sites-available/default file. In the Directory Section for /var/www/, I added, AllowOverride All and restarted Apache Web Server. Now, when try to access the members directory, I am prompted to enter the username and password. However, after I enter the correct username and password, I get Internal Server Error. Any suggestions? The hash and salt are correct.
    – Neon Flash
    Oct 2, 2012 at 8:59
0

Any chance the problem is that you've told Apache to look for the file in /www/Neon/auth/ and you've actually created the file in /var/www/Neon/auth? Put differently, what reason do you have to think Apache understands that the www/Neon/ directory is inside /var/ and not at the filesystem root?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .