加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

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

发布时间:2020-12-14 01:13:21 所属栏目:Linux 来源:网络整理
导读:此功能是基于模块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
此功能是基于模块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/

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读