Configure Apache Password Authentication
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
- <Directory/var/www/html/centos>
- Authtype basic
- Authbasicprovider File
- Authuserfile/var/www/. htpasswd
- Require valid-user
- </Directory>
Authentication is required when accessing the centos directory.
Reference: http://lamp.linux.gov.cn/Apache/ApacheMenu/howto/auth.html
For more information, see https://www.centos.bz/2012/04/apache-password-access/.
Configure Apache Password Authentication