Let me write a detailed description: the specific implementation of Apache user authentication under Win32 (original)

Source: Internet
Author: User
In Win32, Apache user authentication is implemented in many ways. However, in Win32 environments, there are few instructions on how to set Apache user authentication, the manual also describes the configuration in Unix and linux environments. There should be a lot of people who are struggling to explore Apache in win32 like me, based on my experience, I will introduce how to implement a Apache in Win32 environment.

Implement Apache user authentication under Win32
I believe that many verification methods are adopted, but there are few introductions on how to set Apache user authentication in Win32 environment. The manual also describes the configuration in Unix and linux environments, there should be a lot of people who are struggling to explore Apache under win32 like me. Based on my experience, I will introduce how to implement the apache user authentication function in Win32 environment.

Method 1: a single user can only access a directory by a user or several users.
Assume that the Apache web root directory is d:/home, and the corresponding URL is http: // localhost/
To make the d:/home/test directory accessible only to a user, the URL of the directory is http: // localhost/test. a verification dialog box is displayed when you access the URL.
D:/users directory used to store the password file user. passwd

1. create a user password file
In the command line, use the tool htpasswd.exe provided by apacheto generate a password file named user. passwd. the-c parameter indicates the new file, and the parameter no parameter indicates adding a user to the password file.
D: \ apache \ bin> htpasswd-bc d:/users/user. passwd user1 123456
In this way, the d:/users/user. passwd password file is generated, which contains a line of text user1: $ apr1 $4S3 ...... $. su.8AIrDEYMX7jKv2RT9/
A user1 user is added successfully. if you want to add another user, add the user as an append User:
D: \ apache \ bin> htpasswd-B d:/users/user. passwd user2 123456
D: \ apache \ bin> htpasswd-B d:/users/user. passwd user3 123456

Now, after adding a user, you can implement user verification.

2. create an access authentication file. htaccess
Open Notepad and enter the following text:

Authtype basic
Authname "www.home.net"
Authuserfile d:/users. passwd
Require user user1

Save it. htaccess: save the path to the directory you want to verify: d:/home/test/. select "all files" for the save type and the file name is ". htaccess ", otherwise it will not be generated. htaccess file.

By now, the setting of user authentication is completed. enter the address http: // localhost/test/corresponding to the authentication directory in the browser /, A dialog box is displayed in the browser asking you to enter the user name and password. you can only enter user1 and password 12345. it is useless to enter other users, such as user2 and user3.

3. verify a directory by specifying several users
For example, if you decide that http: // localhost/test/can be accessed by user1 and user3, and user2 cannot be accessed, edit the d:/home/test/. htaccess file and put the last sentence:
Require user user1
Changed:
Require user user1 user3
Therefore, http: // localhost/test/can only be accessed by user1 and user2.

4. verify a directory by all valid users
For example, http: // localhost/test/can be determined by d:/users/user. to access all users in the passwd file, edit d:/home/test /. in the htaccess file, change the last sentence:

Require valid-user

In user. passwd, users can access http: // localhost/test/, as long as the user name and password entered are correct.

Method 2: implement verification by using group users
In method 1, users in the user. passwd file are grouped, user group files are created, and authgroupfile is specified in the. htaccess file. Assume that many users (user1, user2, user3, user4,...) have been added to user. passwd ,...)
1. create a user group file d:/users/user. group with the following content:

Manager: user1 user3
Game: user2 user4
Download: user5 user6 user7

In this way, the user. group file divides the seven users from user1 to user7 into three groups: manager, game, and download.

2. enable a group of users to access http: // localhost/test/
Edit the d:/home/test/. htaccess file with the following content:

Authtype basic
Authname "www.home.net"
Authuserfile d:/users. passwd
Authgroupfile d:/users/user. group
Require group game

Therefore, http: // localhost/test/can only be accessed by user2 and user4 in The game Group.

For those familiar with programming and development, the above steps can be completed by a graphical interface program, which saves a lot of trouble.
So far, Simple Authentication of Apache in Win32 environment is implemented. It seems that it is similar to the setting method in Linux, but I took a lot of detours to find out.
There are several ways to verify Apache. the above is only one aspect.
Related Article

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.