1829770 Members
3129 Online
109992 Solutions
New Discussion

Re: APACHE WEB PAGES

 
SOLVED
Go to solution
Nobody's Hero
Valued Contributor

APACHE WEB PAGES

I am running apache on RH9, apache version 2.0.

Is there a way that I can prompt for a user name and password when someone is trying to access certain web pages or documents. Do I do this in the httpd.conf file?
UNIX IS GOOD
2 REPLIES 2
Stuart Browne
Honored Contributor

Re: APACHE WEB PAGES

Usually, this can be done in a number of ways.

The most usual is to use a '.htaccess' file, asking for 'Auth' details. An example perhaps:

AuthType Basic
AuthName SomeAuthName
AuthUserFile /home/www/auth/user-auth.txt

You can use more advance methods (querying a MySQL database, using the shadowing password system, or a dbm file), but that's pretty much it.

In the 'user-auth.txt' you'd have 'user:encpass' pairs of your users. You can also use 'require user ' directives to allow access.

This is usually done on a directory level, not a file-level however. The Apache documentation is very good with regards to this. See http://httpd.apache.org/docs-2.0/howto/auth.html for a how-to walk-through.

The other way to do it is to program it yourself in PHP. Once again, this is very well documented. See http://www.php.net/manual/en/features.http-auth.php for more details on that.
One long-haired git at your service...
Senthilmurugan
Frequent Advisor
Solution

Re: APACHE WEB PAGES

Yes, you can do Authentication based Access system to the Web pages to be accessed.

You can create a username/password file using "htpasswd" executable which comes with Apache and will be present in "bin" directory of the apache installed location.
go to the location htpasswd exist
then,
#./htpasswd -c passwordfile username
New password:
Re-type new password:
Adding password for user username
#

In the http.conf file

Under the Directory tab


AuthUserFile /PATH/TO/THE/PASSWD/FILE
AuthName "Enter the username/passwd"
AuthType Basic
Require valid-user
Options FollowSymLinks


now restart the apache server
It will promt you for the username and passwd when you are trying to access the particular location in the browser.

Regards,
Senthil Murugan