// 1. httpd in the Apache server of the website. the conf file is set to DocumentRoot/var/www/html // This path is the default folder path opened when the external IP address of the Linux server is set in Apache. It must be the complete path accessfilename. htaccessallowoverride all // 2, Linux Command htpasswd-C allowuser /. htpasswd newuser // create in the allowuser folder under the current directory. create a newuser user in the htpasswd file, and then prompt to set the password .. Put the htpasswd file in a folder under/var/www/instead of/var/www/html to prevent users who can access the HTML folder from modifying its content. // 3, add it to the folder to be accessed (the folder must be under the/var/www/html path or the/var/www/html path itself. and write authname "section name" authtype basicauthuserfile/var/www/allowuser /. htpasswd // enter the one you just created. the complete path of the htpasswd file is require valid-user // 4, and the file is finally set. htpasswd and. make sure that the Apache user has the read permission for the htaccess file. Therefore, the permission is required when accessing the webpage under this folder. username and password in the htpasswd File