User authentication of Apache under Win32

xiaoxiao2021-03-06  41

I believe there are many kinds of verification methods, and how to set up Apache user authentication in the Win32 environment, the manual is also the configuration in the UNIX and Linux environment, like me in Win32 hard-groping Apache, should Many, I introduced my own experience to how my own user verification function is implemented in the Win32 environment.

Method 1: Implement a directory in a single user manner can only be accessed by a user or several users.

Suppose the Apache's web root directory is D: / HOME, the corresponding URL is

http: // localhost /

To make the d: / home / Test directory can only be accessed by a user, the directory corresponds to the URL

Http: // localhost / test, you need to pop up the verification dialog when accessing the URL.

D: / users directory to store password file user.passwd

1, make user password files

In the command line, use Apache's own tool htpasswd.exe to generate a password file called User.Passwd, the -c parameter represents a new file, no parameters indicate an additional user in this password file.

D: / apache / bin> htpasswd -bc d: /users/user.passwd user1 123456

This way, generates a D: /Users/User.Passwd password file, there is a line of text User1: $ APR1S3 ..... $. Su.8airdeymx7jkv2rt9 /

Successfully added a user1 user, if you want to add another user, add users to add users:

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 add a user, you can start to implement the user's verification.

2, make access verification files .htaccess

Open Notepad, enter the following text:

Authtype Basic

Authname "www.home.net"

Authorfile D: /users/Users.passwd

Require User1

Then save the .htaccess, save the path for the directory you want to implement: D: / Home / Test / Under / Test, pay attention to the Save Type Select All Files, the file name ".htaccess", otherwise it will not generate .htaccess file .

Here, specifying a user verification setting is completed, enter the address corresponding to the verification directory in the browser

Http: // localhost / test /, you will find that the browser pops up a dialog requires you to enter your username and password. You can only enter the user USER1 and password 12345 to enter, enter other users such as USER2, User3 is useless.

3. Implement a specified verification of a number of users to a directory

, For example, decision

Http: // localhost / test / can be accessed by user1 and user3, user2 cannot access, then edit the d: /Home/test/.htaccess file, put the last sentence:

Require User1

Change to:

Require User1 User3

This is achieved so

http: // localhost / test / can only be accessed by User1 and User2

4. Implement all legal users to a directory verification

, For example, decision

Http: // localhost / test / can be accessed by all users in the D: /Users/User.Passwd file, then edit the D: /Home / Test/.htaccess file, change the last sentence to: Require Valid-User

You can be able to access users in user.passwd

http: // localhost / test /, as long as the username and password are not wrong.

Method 2: Implementation of the group user mode

To achieve, it is also very simple. In the method one, you can group users in the user.passwd file, establish a user group file, and then specify the authgroupfile in the .htaccess file. Suppose many users have been added in User.Passwd (User1, User2, User3, User4, ...)

1. Create a user group file D: /users/User.group, the content is as follows:

Manager: User1 User3

Game: User2 User4

Download: User5 User6 User7

In this way, the User1 to User7 is divided into 3 groups in the user.group file: Manager, Game, Download.

2. Implement a group of users can access

Http:// localhost / test /

Edit D: /Home/test/.htaccess file, the content is as follows:

Authtype Basic

Authname "www.home.net"

Authorfile D: /users/Users.passwd

Authgroupfile D: /users/user.group

Require Group game

Then

http: // localhost / test / can only be accessed by users used by users in the GAME group.

The above steps, for familiar programming development, you can do a graphical interface program to complete, there are more people.

At this point, the simple verification of Apache is implemented in the Win32 environment. It seems that the settings under Linux are almost the same, but I have gone a lot of bending roads to explore, and I am embarrassed.

There are still several ways to implement Apache's verification methods, and the above is only one aspect.

转载请注明原文地址:https://www.9cbs.com/read-59252.html

New Post(0)