实验:basic验证

1 vim /etc/httpd/conf.d/test.conf 创建一个文件

authtype basic 基于账号密码验证登录
AuthName "admin Page"
AuthUserFile "/etc/httpd/conf.d/.httpuser" 用户的账号密码存放路径
Require user tom alice 允许登录的用户,如果允许所有人登录Require valid-user

2 htpasswd -c /etc/httpd/conf.d/.httpuser tom 添加用户 没有.httpd这个文件就自己创建,有文件的话不要加-c 不然会覆盖你之前的文件(命令,文件,用户)
password:**
password:**
3 chmod 600 /etc/httpd/conf.d/.httpuser 给予文件权限
setfacl -m u:apache:r /etc/httpd/conf.d/.httpuser 授权

实验:basic方法2 .htaccess

1vim /var/www/html/admin/.htaccess
authtype basic
AuthName "admin Page"
AuthUserFile "/etc/httpd/conf.d/.httpuser"
Require user tom alice

2
vim /etc/httpd/conf.d/test.conf

allowoverride authconfig

实验:basic对组实现验证

1
vim /etc/httpd/conf.d/.httpgroup 创建G1,G2 组
g1: tom jack 组成员
g2: tom alice 组成员
2
vim /var/www/html/admin/.htaccess
authtype basic
AuthName "admin Page"
AuthUserFile "/etc/httpd/conf.d/.httpuser"
AuthGroupFile "/etc/httpd/conf.d/.httpgroup"
Require group g1 g2 允许G1,G2组成员访问