码迷,mamicode.com
首页 > Web开发 > 详细

linux实现家目录的web共享,并基于basic验证

时间:2019-05-13 10:55:14      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:tor   include   echo   follow   includes   wan   disabled   htaccess   file   

此功能是基于模块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/

linux实现家目录的web共享,并基于basic验证

标签:tor   include   echo   follow   includes   wan   disabled   htaccess   file   

原文地址:https://blog.51cto.com/9019400/2393410

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!