Web service configuration and application 3-Linux Enterprise Application-Linux server application information. The following is a detailed description. 10. User Authentication: the following uses an actual example to describe the user authentication method.
Assume that there is a virtual directory named mysecret, and its corresponding path is/usr/local/mysecret. First, you need to enable the user authentication function for it and only allow users named linden and tom to access it.
Create a password file: The htpasswd Command provided by Apache provides the ability to create and update text files that store user names and passwords. Note that this file cannot be placed in a path that can be accessed by the network. In this example
Htpasswd-c/etc/httpd/mysecretpwd linden
Htpssswd/etc/httpd/mysecretpwd tom # resume two user names and enter the password to generate a password file
Create a virtual directory and configure user authentication: Add the following statement to the httpd. conf file of Apache's main configuration file.
Alias/mysecret "/usr/local/mysecret"
AuthType Basic # Set the authentication type
AuthName "this is a private directory. Please Login:" # Set authentication domain content
AuthUserFile/etc/httpd/mysecretpwd # Set the location of the password file
Require user linden tom # Set the Users Allowed to access
Test user authentication: restart the service by using/etc/init. d/httpd restart on the server.
Enter/Server IP Address/mysecret in the url
Note: I have created an index.html file under/usr/local/mysecretwith the attribute 644.
The method above the file attribute of/etc/httpd/mysecret is set to 600. In the preceding operations, a Login Dialog Box is displayed, requiring you to enter the user name and password. However, I cannot use the input. I don't know why, but I added the chmod o + r mysecretto the attributes of the/etc/httpd/mysecret file to access the index.html webpage I wrote first, there is no logon box that requires the user name and password. I am using rh9 linux. Could someone take rhel4's friend to give an experiment and see if it is a version or if rh9 can solve the problem? Please let me know. Thank you !!
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