Apache Configuration

Hi,

I'm new to Linux. Please help me out to configure apache to require a username and password to access certain documents.

Eg. Say I have "main.html" and other associated files in /usr/temp. I want to restrict the access to the main.html page by providing a username and password. Once a valid username and password are provided the user should be provided access to view this page and the further html files associated with this main.html.

Appreciate if any one of you could provide me detailed step by step procedure, illustrating with an example.

Thanks
Tamma
tammarAsked:
Who is Participating?
 
bcolemanCommented:
Here is how from the apache week web site.  http://www.apacheweek.com/features/userauth

or when you first set up apache it came up with documentation that you could browse through.  Go to Frequently asked questions #46.  Hope that helps
0
 
tammarAuthor Commented:
Hi,

I have configured the apache as specified in the documentation but no luck. Its not prompting for the user name and password.

I will explain you what I have done.
1) Created a index1.html file in /home/httpd/html/html1
2) The .htaccess file is in /home/httpd/html/html1
3) The .htaccess file looks like this
          AuthName ByPassword
          AuthType Basic
          AuthUserFile /etc/httpd/users

          require user tammar
4) In "access.conf" included the line
   AllowOverride AuthConfig
to allow the authentication directive thru' .htaccess file.
5) stoped and started httpd.

In the GNOME when i tried to access the index1.html file thru' Netscape Communicator, it's not prompting for the user and the password.

Appreciate if you could help me out.

Note : index1.html is a copy of the file index.html in /usr/doc/HTML.

Thanks
Tammar
0
 
bcolemanCommented:
Have you tried to access it from a Windows based client?  Have you tried restarting your browser?
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
tammarAuthor Commented:
Its not right now connected to the net(internet), its only on local network and iam giving the followig command in the "Location" of the browser

file://home/httpd/html/html1/index1.html.

I have restarted the browser all the time i tested.

I have not tried to access it from Windows bases client.
0
 
bcolemanCommented:
It will not prompt you for the username and password if you just access the file, because you are not using the apache server to access the file.  Instead you are just reading the file, which you can do without apache.  Try accessing it this way instead http://127.0.0.1/home/httpd/html/html1/index1.html.
0
 
bcolemanCommented:
The 127.0.0.1 does not work I tried it try your host name instead of 127.0.0.1.  In your browser type http://hostname/ do not use www or just use http://ipaddress/ if you do not have a dns setup.
0
 
tammarAuthor Commented:
I tried with

http://ipaddress/home/httpd/html/html1/index1.html
http://hostname/home/httpd/html/html1/index1.html

Now it does prompt for the username and password but it says

The requested URL http://ipaddress/home/httpd/html/html1/index1.html
not found on this server.
0
 
bcolemanCommented:
In your access.conf what is the default directory?  is it /var/www?  if so try to put your index1.html in that directory and rename it to index.html (save the old one if there is one) and try to connect http://hostname
also put your .htaccess in that directory.
 
0
 
tammarAuthor Commented:
The default directory (Document Root) is /home/httpd/html.
0
 
bcolemanCommented:
0
 
tammarAuthor Commented:
It works with the above comment.

But why doesn't it take the complete path?

Thanks for your consistent help.

Tammar
0
 
bcolemanCommented:
Hostname gets you to the default directory then you are just adding on from there.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.