Sometimes, we need to give some special access to set up a user authentication mechanism to increase security! The essence of Apache user authentication is to give users access to add a password authentication process, before introducing the Apache certification to introduce a tool to create a password htpasswd!
#/usr/local/apache2/bin/htpasswd parameter:-C: Create a new password file-D: Delete a user-M: Encrypted with MD5 encoding-D: Crypt encoded encryption, this is the default way -P: Password in plaintext format-s: With SHA encoded encryption
First open the corresponding virtual host configuration file
Vim/usr/local/apache2/conf/extra/httpd-vhosts.conf
Add the following configuration to the corresponding virtual host
<DIrectory/data/www/abc>//Specify the directory to be certified allowoverride authconfig authname "ABCD"//Set up users with authentication , the description will appear in the dialog box of a question displayed to the user's password AuthType basic//encryption method, Basic authentication does not encrypt the address from the user's browser authuserfile/data/.htpasswd//below Password file to create require Valid-user//set Allow access to users </Directory>
Create a user for authentication
#/usr/local/apache2/bin/htpasswd-cm/data/.htpasswd user1
Enter after entering the set password, the first time to create a user to add the-C option, the second time directly created without adding-c! When using HTPASSWD to create a user password, if the current directory is no longer/usr/local/apache2/bin, write/usr/local/apache2/bin/htpasswd, or you can add the path variable, it is not so troublesome, Direct htpasswd is possible!
Be sure to restart the Apache service after setting up the virtual host:
/USR/LOCAL/APACHE2/BIN/APACHECTL-T//Detect configuration file is correct/usr/local/apache2/bin/htpasswd restart//restart Apache service
This article is from the "Custom" blog, so be sure to keep this source http://zidingyi.blog.51cto.com/10735263/1708190
Apache User authentication Configuration