Apache user authentication
Open the site directly pop-up user name password, correct before you can view the site, this is called Apache user authentication.
Edit the configuration file (because we are using Apache virtual host, so we enter the configuration of the virtual host)
vim /usr/local/apache2.4/conf/extra/httpd-vhosts.conf
Add the following paragraph to the configuration file
<Directory /data/wwwroot/yy.com>
Specify the directory for authentication
AllowOverride AuthConfig
This is equivalent to turning on the authentication switch
AuthName "yy.com user auth"
The name of the custom authentication is not very useful
AuthType Basic
The type of authentication, generally basic,
AuthUserFile /data/.htpasswd
Specify where the password file is located
require valid-user
Specify the user who needs authentication for all available users
</Directory>
Create a password file and user and password
/usr/local/apache2.tpasswd-c-m/data/.htpasswd KJJ
Apache user authentication, domain jump, Apache access log