I'll write a detailed: Win32 under the specific implementation of Apache user authentication (original)

Source: Internet
Author: User
Tags implement require win32 access linux
apache| original Win32 under the specific implementation of Apache user authentication
I believe that many of the verification methods used, and in the WIN32 environment how to set the Apache user authentication is very little, the manual is also described in the UNIX and Linux environment configuration, like me in the Win32 under the hard groping Apache should be a lot of people, I have based my experience on how to implement the Apache user authentication function in WIN32 environment.

Method One: Implementing a directory as a single user can only be accessed by one user or several users.
Assuming that Apache's Web root is D:/home, the corresponding URL is http://localhost/
If you want to make the D:/home/test directory accessible only to a single user, the directory corresponds to the Http://localhost/test URL, and you need to eject the Validation dialog box when accessing the URL.
The D:/users directory is used to store password files user.passwd

1, the production of user password files
In the command-line mode first with the Apache tool Htpasswd.exe to generate a password file called User.passwd,-c parameter represents a new file, no parameter means that in the password file to add a user added way.
D:\APACHE\BIN>HTPASSWD-BC d:/users/user.passwd user1 123456
This generates the D:/USERS/USER.PASSWD password file, which has a line of text user1: $apr 1$4s3.....$.su.8airdeymx7jkv2rt9/
Successfully added a User1 user, if you want to add another user, add the user by appending:
D:\apache\bin>htpasswd-b d:/users/user.passwd user2 123456
D:\apache\bin>htpasswd-b d:/users/user.passwd User3 123456

OK, when you are finished adding users, you can start to implement user authentication.

2. Make access verification documents. htaccess
Open Notepad and enter the following text:

AuthType Basic
AuthName "Www.home.net"
AuthUserFile d:/users/users.passwd
Require user User1

Save the path as. htaccess the directory you want to validate: d:/home/test/, note the Save type Select all files, and the file name is ". htaccess", otherwise No. htaccess file is generated.

Here, specify a user authentication settings are completed, in the browser to enter the corresponding address http://localhost/test/, you will find that the Browser pop-up dialog box requires you to enter a username and password, you can only enter the user User1 and password 12345 in order to go in , it is useless to enter other users such as User2,user3.

3, the implementation of a certain number of users to specify a directory verification
For example, the decision http://localhost/test/can be accessed by User1 and User3, User2 cannot be accessed, then edit the d:/home/test/.htaccess file and put the last sentence:
Require user User1
To
Require user User1 User3
This is achieved http://localhost/test/can only be accessed by User1 and User2.

4, the realization of all legitimate users of a directory verification
For example, to decide that http://localhost/test/can be accessed by all users in the d:/users/user.passwd file, edit the d:/home/test/.htaccess file and change the last sentence to read:

Require Valid-user

Can be implemented in USER.PASSWD users can access the http://localhost/test/, as long as the user name and password entered without errors.

Method Two: Using the group user method to realize the verification
To achieve it is also very simple, in method one of the users in the USER.PASSWD file group, set up a user group file, and then in the. htaccess file to specify the AuthGroupFile. Suppose a lot of users have been added to the USER.PASSWD (User1,user2,user3,user4,...)
1, the establishment of a user group file D:/users/user.group, the contents are as follows:

Manager:user1 User3
Game:user2 User4
Download:user5 User6 User7

Thus, the User1 to User7 7 users in the User.group file are divided into 3 groups: Manager,game,download.

2, to achieve a group of users can access http://localhost/test/
Edit the D:/home/test/.htaccess file as follows:

AuthType Basic
AuthName "Www.home.net"
AuthUserFile d:/users/users.passwd
AuthGroupFile D:/users/user.group
Require group game

Then, http://localhost/test/can only be accessed by the users in the game group User2,user4.

The above steps, for familiar with programming development comrades, can do a graphical interface program to complete, it is more convenient.
So far, the simple verification of Apache in the WIN32 environment is realized. It seems to be the same as the Setup method under Linux, I have gone a lot of detours before groping out, ashamed of AH.
There are several ways to implement the Apache verification method, which is only one aspect.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.