Settings for apache-set user authentication for directories or files
Set up user authentication for a directory or file
Add the following configuration to the corresponding CVM configuration file:
AllowOverride AuthConfig
AuthName "The administrator authentication!"
AuthType Basic
AuthUserFile / data/.htpasswd
Require valid-user
The path after Directory is the directory or file to be authenticated by the user, AuthName followed by a custom verification prompt, and AuthUserFile followed by a verification file.
Create a verification file using htpasswd, a tool that comes with apache:
# / usr/local/apache2/bin/htpasswd-cm / data/.htpasswd username
New password:
Re-type new password:
Adding password for user username
# cat / data/.htpasswd
Username:$apr1 $wLVEgNIh$Ne.IU7FgjfPBZsP6SocZ11
The parameter-c means to create a new file, and-m means to encrypt the password with MD5, followed by the path to the authentication file. Username is the user name.
# / usr/local/apache2/bin/apachectl-t
Syntax OK
Check that the configuration file is correct
# / usr/local/apache2/bin/apachectl graceful
Graceful means to reload the configuration file