alias /phpredis "/var/www/html/phpredis"
<Directory /var/www/html/phpredis>
Options Indexes MultiViews
AuthType basic
AuthName "welcome test"
AuthUserFile /etc/httpd/.htpasswd
require valid-user = user test #如有其它用户以此 列在 test 之后
</Directory>
htpasswd -c /etc/httpd/.htpasswd 用户名
#第一次创建用户要用到-c 参数 第2次添加用户,就不用-c参数
htpasswd -m .htpasswd 用户名 更改密码
htpasswd -D .htpasswd 用户名 删除用户
重启apache
==================================
通过用户组方式访问
alias /test01 "/data/web/test01/"
<Directory /data/web/test01>
Options Indexes MultiViews
AuthType basic
AuthName "welcome test"
AuthUserFile /etc/httpd/httppwd
AuthGroupFile /etc/httpd/httpgrp #用户组文件路径
require group admin #admin 是用户组
</Directory>
创建用户组配置文件
vi /etc/httpd/httpgrp #创建路径与配置文件中指定文件相同
内容如下:admin:test #注意test 是已经创建好的用户,如果该组中有其它用户,一次排列以空格隔开