1. 程式人生 > >linux實現家目錄的web共享,並基於basic驗證

linux實現家目錄的web共享,並基於basic驗證

str bob control only 目錄 名稱 include info 用戶組

此功能是基於模塊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驗證