[glugot] got soln for http authentication in apache

  • From: suresh babu <mail2mbabu@xxxxxxxxxxx>
  • To: glugot@xxxxxxxxxxxxx
  • Date: Sun, 23 Jan 2005 20:53:34 -0800 (PST)

i give you the conversation we had in forums+mail with
pcquest editor regarding this....

i append the coversation below

Dear members, please help me:
Visit www.tceplexus.com/cpanel it asks for a username
and password. I want it like that. 

Please help me (sureshbabu_m@xxxxxxxxx)

solution to the above problem from mr shekar---pcquest
This is achieved by using HTTP authentication.
Following are the steps to set up HTTP authentication
with Apache on Linux: 

Assume that there is a directory named it4e in
/var/www/html for which the HTTP authentication is to
be setup. 

1. Open the file named httpd.conf found in
/etc/httpd/conf in a text editor. Scroll down to the
line which says: 

<Directory ?/var/www/html?> 

2. Scroll down a little further to find the line: 

AllowOverride None 

and change it to: 

AllowOverride AuthConfig 

3.Save the httpd.conf file and restart the web server

service httpd restart 

4.Select a directory where you intend to store the
authentication credentials for the sites. Say
/etc/httpd/conf/htpasswd. Create the directory
htpasswd under /etc/httpd/conf/. 

5.Create the authentication credential file and insert
a user named shekhar (say) by using the following

htpasswd -c /etc/httpd/conf/htpasswd/it4e shekhar 

When prompted enter and confirm your preferred

6. Optionally to create another user (say admin): 

htpassword /etc/httpd/conf/htpasswd/it4e admin 

Note the omission of -c switch which is used to create
the authentication file only for the first time. 

7.Open a text editor and type in following contents: 

AuthType Basic 
AuthName "IT4E" 
AuthUserFile /etc/httpd/conf/htpasswd/it4e 
Require valid-user 

Substitute AuthName to the website name and
AuthUserFile to the location of the authentication
credential file in your case. The line: 

Require valid-user 

specifies that any user in the file (created using
htpasswd) can authenticate. Alternatively, this line
can be changed to 

Require shekhar 

This will allow login only with username shekhar and
the corresponding password. 

8.Save the above file as .htaccess in the directory

9.Subsequently an access to http://<server-name>/it4e
should pop up an authentication box.
The above solution did not work my new problem is :
Dear Sir, 
I had done everything you had mentioned and now when i
type the url it pops up for a password. But even if i
give correct password. it says authentication denied.
I had tried plenty of times but still the same result.

Pleae help me ...what could be my mistake. 

Again Soln added by mr shekar--->pcquest is
I guess this is happening because apache is not able
to read the 
password file. Going by the example, try this: 

chown apache.apache /etc/httpd/conf/htpasswd/it4e 

If this works, please post the the same on the forum
so that it helps 
others. Thanks 


Now If i key in the url http://<my-ip>/samplesite

it will ask for a uid and password; and http
authentication is done correctly.

Bye With Regards From

Suresh Babu M


Suresh Babu M

Do you Yahoo!? 
Take Yahoo! Mail with you! Get it on your mobile phone. 

GLUGOT = GNU/Linux User Group Of TCE
visit: http://www.glugot.tk /
(TCE students, check TCENet for GLUGOT website)

Other related posts:

  • » [glugot] got soln for http authentication in apache