Sometimes we need some special access to set up a user authentication mechanism, add security, such as a directory of our site, we just want to give specific people to view, other people do not see. We can encrypt authentication for this directory.
--------------------------------------------------------------------------------------------------------
# vi/usr/local/apache2/conf/extra/httpd-vhosts.conf
Add the following red Font section to the corresponding virtual host configuration
<virtualhost *:80>
DocumentRoot "/data/www"
ServerName www.test.com
<Directory/data/www/abc/>
AllowOverride authconfig
AuthName "Custom"
AuthType Basic
authuserfile/data/.htpasswd
Require Valid-user
</Directory>
</VirtualHost>
--------------------------------------------------------------------------------------------------------
#/USR/LOCAL/APACHE2/BIN/HTPASSWD-CM/DATA/.HTPASSWD Test Create authenticated user
New Password: Set password
Re-type New password: Confirm password
Adding Password for user Liuqi Add authentication User Success
--------------------------------------------------------------------------------------------------------
Then restart the Apache service
#/usr/local/apache2/bin/apachectl-t
Syntax OK
Check that the configuration is correct first
/usr/local/apache2/bin/apachectl Graceful
--------------------------------------------------------------------------------------------------------
All OK, self test!
This article from "Youth A Little Flood" blog, declined reprint!
Apache user authentication