Apache provides a series of authentication, authorization, and access control modules. here we use the most convenient mod_auth_basic, mod_authn_file, and mod_authz_user modules to implement directory or file authentication by entering users and passwords. 1. example of generating a password file: htpasswd-c/var/www/. htpasswdcentos/var/www/. htpasswd is the location of the password file.
Apache provides a series of authentication, authorization, and access control modules. here we use the most convenient mod_auth_basic, mod_authn_file, and mod_authz_user modules to implement directory or file authentication by entering users and passwords.
1. generate a password file
Example:
Htpasswd-c/var/www/. htpasswd centos
/Var/www/. htpasswd is the location of the password file
Centos is an authorized user.
Htpasswd tool detailed instructions: http://lamp.linux.gov.cn/Apache/ApacheMenu/programs/htpasswd.html
2. configure the httpd. conf file
AuthType basic
AuthBasicProvider file
AuthUserFile/var/www/. htpasswd
Require valid-user
Authentication is required when accessing the centos directory.
Reference: http://lamp.linux.gov.cn/Apache/ApacheMenu/howto/auth.html