此功能是基于模块mod_userdir.so实现
1 vim /etc/httpd/conf.d/userdir.conf
<IfModule mod_userdir.c>
#UserDir disabled
UserDir public ##指定共享目录的名称
</IfModule>
#
# Control access to UserDir directories. The following is an example
# for a site where these directories are restricted to read-only.
#
#<Directory "/home/*/public_html">
# AllowOverride FileInfo AuthConfig Limit Indexes
# Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
# Require method GET POST OPTIONS
#</Directory>
<directory /home/wang/public> #目录授权
allowoverride authconfig #启用目录.htacces配置文件
</directory>
2 vim /home/wang/public/.htaccess
authtype basic #启用basic验证
AuthName "admin Page" #主页名字
AuthUserFile "/etc/httpd/conf.d/.httpuser" #用户名单
AuthGroupFile "/etc/httpd/conf.d/.httpgroup" #用户组
Require group g1 g2 #授权的用户组
3
htpasswd -c /etc/httpd/conf.d/.httpuser tom
root:~ # cat /etc/httpd/conf.d/.httpuser
bob:$apr1$uiGJnnta$malpOQNXO1H6PXkSFBQLp.
tom:$apr1$G3CLOH6u$3azhfaSvBcQKnd2sHrYdo1
alice:$apr1$TMnblcB2$ui69X.78BLx.yYg9igwAW0
4
mkdir ~wang/public
echo 'test1\' > /~wang/public/index.html
setfacl -m u:apache:x ~wang/
4测试
访问 http://YOU-ip/~wang/
转载于:https://blog.51cto.com/9019400/2393410